Call into the IActionResultFactory only if the return value isn't IActionResult.

This commit is contained in:
David Fowler 2013-12-14 15:58:06 -08:00
parent e87e819b14
commit 81a4cfbfbf
2 changed files with 2 additions and 8 deletions

View File

@ -7,13 +7,6 @@ namespace Microsoft.AspNet.Mvc
{
public IActionResult CreateActionResult(object actionReturnValue)
{
var actionResult = actionReturnValue as IActionResult;
if (actionResult != null)
{
return actionResult;
}
var responseMessage = actionReturnValue as HttpResponseMessage;
if (responseMessage != null)
{

View File

@ -47,7 +47,8 @@ namespace Microsoft.AspNet.Mvc
object actionReturnValue = method.Invoke(controller, null);
IActionResult actionResult = _actionResultFactory.CreateActionResult(actionReturnValue);
// If it's not already an IActionResult then call into the factory
var actionResult = actionReturnValue as IActionResult ?? _actionResultFactory.CreateActionResult(actionReturnValue);
return actionResult.ExecuteResultAsync(_requestContext);
}