提高 ASP.NET MVC 启动性能
我正在尝试提高 MVC2 应用程序的启动速度。
我进行了第一轮性能采样,看起来它
MvcAreaRegistration.RegisterAllAreas
占用了大部分启动时间。
我在此处读到您可以也手动注册该区域,我想尝试一下,但我不确定该页面上的语法如何工作。
所以我的(第一)问题是:如何手动注册我的区域?
I'm trying to improve the speed at which my MVC2 app is starting up.
I did a first round of performance sampling, and it appears that the
MvcAreaRegistration.RegisterAllAreas
is taking up most of the startup time.
I read here that you can manually register the area's as well, and I would like to try that out, but I'm not sure how the syntax works on that page.
So my (first) question woud be: how can I register my Area's manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以完全手动完成此操作并避免使用 RegisterArea 实现。
检查这篇文章:
http://www.philliphaydon.com/ 2011/07/mvc-areas-routes-order-of-routes-matter/
简而言之 - 您需要将“area”DataToken 添加到您的路线中:
You can do this completely by hand and avoid using RegisterArea implementations.
Check this article:
http://www.philliphaydon.com/2011/07/mvc-areas-routes-order-of-routes-matter/
In short - you need to add "area" DataToken to your route:
尝试 这个超级方便的区域注册实用程序。它不仅使注册变得更容易,而且速度更快,因为它不会扫描每个加载的程序集的区域。
Try this super handy area registration utility. Not only does it make registration easier, but also way faster since it doesn't scan every loaded assembly for areas.
首先在 Global.asax 中准备一个辅助方法,如下所示:
现在您可以使用此辅助方法在 Application_Start 中手动注册,如下所示:
AreaRegistration 类是在您添加新区域时由 Visual Studio 创建的,您可以在 Areas/AreaName 中找到它们目录。
First prepare yourself a helper method in Global.asax like this:
Now you can use this helper method for manual registration in Application_Start like this:
The AreaRegistration classes are created by Visual Studio when you add new Area, you can find them in Areas/AreaName directories.