Wednesday, 16 January 2013

Removing the WebForms View Engine in MVC

If Razor is the only view engine you use in an ASP.NET MVC application, then it makes sense to remove the Web Forms view engine and save some cycles. Otherwise, the MVC runtime will go looking for .aspx and .ascx files when it tries to locate a view or template. A small savings, but just 2 lines of code required during application startup.

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());