diff --git a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionExecutor.cs b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionExecutor.cs index e223b5224a..c9d9f568dd 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionExecutor.cs @@ -60,7 +60,8 @@ namespace Microsoft.AspNet.Mvc // This is necessary to enable calling await on the returned task. // i.e we need to write the following var result = await (Task)mInfo.Invoke. // Returning Task enables us to await on the result. - private static async Task CoerceResultToTaskAsync( + // This method is intentionally not using async pattern to keep jit time (on cold start) to a minimum. + private static Task CoerceResultToTaskAsync( object result, Type returnType, string methodName, @@ -74,7 +75,7 @@ namespace Microsoft.AspNet.Mvc if (returnType == typeof(Task)) { ThrowIfWrappedTaskInstance(resultAsTask.GetType(), methodName, declaringType); - return await CastToObject(resultAsTask); + return CastToObject(resultAsTask); } var taskValueType = TypeHelper.GetTaskInnerTypeOrNull(returnType); @@ -84,7 +85,7 @@ namespace Microsoft.AspNet.Mvc // constructs: return (Task)Convert((Task)result) var genericMethodInfo = _convertOfTMethod.MakeGenericMethod(taskValueType); var convertedResult = (Task)genericMethodInfo.Invoke(null, new object[] { result }); - return await convertedResult; + return convertedResult; } // This will be the case for: @@ -96,7 +97,7 @@ namespace Microsoft.AspNet.Mvc } else { - return result; + return Task.FromResult(result); } }