What does [ASP.net] MVC do before my controller?

I have a slightly strange performance problem related to my MVC controller or, rather, before it?

According to the Mini Profiler output, before reaching my controller, the overhead is 120m.

Does anyone know why this would be? This is on a server (not local) that has Compilation debug=false , so it is not a problem not to work in release mode.

Everything after it, I can configure / change, but before that? and i got lost ..

Thoughts ??

enter image description here

Update

After some performance tools, I came across a description of the link here and enter the link here , resulting in:

The most expensive stacks ------------------------------------ System.Web.HttpApplication + CallHandlerExecutionStep.System.Web .HttpApplication. IExecutionStep.Execute System.Web.HttpApplication.ExecuteStep System.Web.HttpApplication + PipelineStepManager.ResumeSteps System.Web.HttpApplication.BeginProcessRequestNotification System.Web.HttpRuntime.ProcessRequestNotificationProcessRequestPotimePpentmentprocessPotentPrementProcessNotificationProcessRequestPotentPrementProcessNotificationProcessNotificationProcessRequestPotentPrementProcessNotePrementProcessNotificationProcessNotificationProcessNotificationProcessNotificationProcessNotificationProcessNotificationProcessNotificationProcessNotificationProcessNotificationProcessNotimeProcessNetificationProcessNotimeProcessNetificationProcessNotimePpelmentPreportProtentProtentProcessNotificationProcessNotProcessNotePreportProtentProtentPrementpostuntepreportpowerprocessNotificationprocess ProcessRequestNotification System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper System.Web.Hosting.PipelineRuntime.ProcessRequestNotification ===> Cost (1716011)

Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp Microsoft.Practices.ObjectBuilder2 .BuilderContext.NewBuildUp Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp Microsoft .Practices.Unity.UnityContainer.DoBuildUp Microsoft.Practices.Unity.UnityContainer.DoBuildUp System.Web.Mvc.Default Control Mvc.MvcHandler + <> c__DisplayClass6.b__2 System.Web.Mvc.SecurityUtil + <> c__DisplayClassb`1.b__a System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust System.Web.HttpApplication + CallHandlerExecutionStep.System.Web.Hxpec.ecxecpec.ecpept.ecpec.ecpept.ecxecpec.ecpept.ecpute .HttpApplication.ExecuteStep System.Web.HttpApplication + PipelineStepManager.ResumeSteps System.Web.HttpApplication.BeginProcessRequestNotification System.Web.HttpRuntime.ProcessRequestNotificationPrivate.pipelpipelperpostelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelpipelperpel .UnsafeIISMethods.MgdIndicateCompletion System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper System.Web.Hosting.PipelineRuntime.ProcessRequestNotification ===> Cost (936006)

Microsoft.Win32.Win32Native.CoCreateGuid StackExchange.Profiling.Timing..ctor StackExchange.Profiling.MVCHelpers.ProfilingViewEngine.Find System.Web.Mvc.ViewEngineCollection + <> c__DisplayClassc.b__a System.Web.Mvc.Fold.Evine.Fvlection.clvlection.clv.Fvlection.clv.wbindmodell Mvc.ViewEngineCollection.Find System.Web.Mvc.ViewResult.FindView System.Web.Mvc.ViewResultBase.ExecuteResult System.Web.Mvc.ControllerActionInvoker + <> c__DisplayClass1c.b__19 System.Web.Mvc.ControllerActionAverRactervector .ControllerActionInvoker.InvokeActionResultFilter System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters System.Web.Mvc.ControllerActionInvoker.InvokeAction System.Web.Mvc.Controller.ExecuteCore System.WebVM.c.ecec.c.ececc.c.ececc.c.ececc.c.ececc.c.ececc.c.ececc.c.ececc.c.ececc.vecvec.vecvec.vecvc. c__DisplayClass6 + <> c__DisplayClassb.b__5 System.Web.Mvc.Async.AsyncResultWrapper + <> c__DisplayClass1.b__0 System.Web.Mvc.MvcHandler + <> c__DisplayClasse.b__d System.Web.HttpAppec + utionStep.System.Web.HttpApplication.IExecutionStep.Execute System.Web.HttpApplication.ExecuteStep System.Web.HttpApplication + PipelineStepManager.ResumeSteps System.Web.HttpApplication.BeginProcessRequestNotification System.Web.HttpRuntime.ProcessRequestNotificationPrivate System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper System.Web.Hosting.

Can a single whole cause some problems?

+6
source share
2 answers

You should look at The ASP.NET MVC Pipeline

The ASP.NET MVC pipeline can be divided into the following parts -

  • App initialisation - This method allows you to add Route objects to the static RouteTable.Routes collection (which is of type RouteCollection).

  • Routing Part - The routing module attempts to map the incoming URL to the routing table and call the corresponding IRouteHandler.

  • Controller creation - IControllerFactory creates a controller instance based on route parameters and the default naming convention.

  • Action Execution - IActionInvoker determines the method that should be executed, IModelBinder checks and binds the method parameters and IFilterProvider detects the filters that will be applied. The action returns an ActionResult type.

  • View - IViewEngine creates the correct viewing mechanism and the model is passed to the view. Using the model validation provider, validation rules are validated to create client-side validation scripts as well as remote validation scripts

For more information:

 http://blog.stevensanderson.com/2007/11/20/aspnet-mvc-pipeline-lifecycle/ 
+1
source

I'm sorry my english

there are many 1.Application_BeginRequest (and AuthenticateRequest) in the global or some HttpModule
2.filters
3.mvc framework, factory controller, action invoker, etc.
4. When the first time it starts, it cost many to compile il for the native

I think you can use a stopwatch to check how much time was spent executing the code in your action so that you can find out where the point takes a lot of time.

120 ms is not the time to spend before the action starts, I think the time has come to take the action

By the way, 120ms is not so bad

update

 public ActionResult Index() { var profiler = MiniProfiler.Current; using (profiler.Step("action")) { return View(); } } 

enter image description here
this result is higher than the result of running the code so you can see the action - the child only costs 1.9
and http: // ...... cost 302, it includes the controller, action

therefore, you should check the high cost of time inside your action code or outside your action code
in pic, it costs 300+ because it is the 1st run, the 2nd run is just a cost of 4
1st run should be slow

0
source

All Articles