教你50招提升ASP.NET性能(二):移除不用的视图引擎
(2)Remove unused View Engines
招数2:
移除不用的视图引擎
If you're an ASP.NET MVC developer, you might not know that ASP.NET still loads the View Engines for both Razor and Web Forms by default. This can cause performance issues because MVC will normally look for Web Forms views first, before switching over to the Razor views if it can’t find them.
如果你是ASP.NET MVC开发人员,你可能不知道ASP.NET会默认加载Razor和Web Forms两种视图引擎。这可能引起性能问题,因为MVC总是会首先查找Web Forms视图,在不能找到它们的时候才会转向Razor 视图。
You can quickly eliminate this performance issue by adding the following two lines to your Global.asax, in the Application_Start():
你可以在Global.asax,Application_Start()添加下面的两行代码很快地排除这个性能问题
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(newRazorViewEngine());
Goodbye Web Forms View Engine!
再见Web Forms视图引擎!