Time taken between Application_BeginRequest and MVC Controller constructor is too long

我的梦境 提交于 2019-12-11 04:20:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!