问题
I have an MVC page request that takes 1200ms between Application_BeginRequest and Application_EndRequest.
The bulk of this time is between the Application_BeginRequest and the constructor of the MVC controller - 900ms.
I am using Unity as the dependency injector and EF. The controller has 12 repositorys passed in on the constructor.
07:26:40,260 - context_BeginRequest
07:26:40,260 - Application_BeginRequest
07:26:41,180 - Constructor
07:26:41,180 - OnAuthentication
07:26:41,196 - OnAuthentication
07:26:41,321 - OnActionExecuted
07:26:41,352 - OnResultExecuted
07:26:41,352 - EndExecuteCore
07:26:41,352 - EndExecute
07:26:41,399 - Application_EndRequest
回答1:
I would recommend using http://structuremap.github.io/ .. it is more faster and has more features. if you are not using the 12 respos in your first call, you can get object later easily when you need it
Factory.GetInstance(passedInType)
来源:https://stackoverflow.com/questions/40301056/time-taken-between-application-beginrequest-and-mvc-controller-constructor-is-to