Wednesday 4 February 2015

ASP.NET Tips #21 - Remove unused View Engines in MVC

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.

You can quickly eliminate this performance issue by adding the following two lines to your Global.asax, in the Application_Start():

protected void Application_Start()
{
   ViewEngines.Engines.Clear();
   ViewEngines.Engines.Add(new RazorViewEngine());
}

Goodbye Web Forms View Engine!

No comments :

Post a Comment