Month End Sale: Get Extra 10% OFF on Job-oriented Training! Offer Ending in
D
H
M
S
Get Now
Removing the Web Form View Engine for better performance of Razor View Engine

Removing the Web Form View Engine for better performance of Razor View Engine

10 Apr 2024
Advanced
152K Views
2 min read

By default MVC is configured to resolve a view by searching the views that match the Web Form view engine's naming conventions first. After that MVC begins search for the views that match the Razor view engine's naming conventions as shown in below fig.

So, If are not using ASPX views in your MVC applications then the checking four unused locations first for every return View() and Html.RenderPartial is quite wasteful and time consuming. After removing Web Form engine, Razor View Engine will be almost twice as fast with the Web Form engine.

Removing the Web Form (ASPX) view engine

Removing the Web Form view engine is easy in MVC. We can remove all the view engines and add only Razor view engine by using Application_Start event of Global.asax.cs file like as:

 protected void Application_Start() 
{ 
//Remove All Engine
 ViewEngines.Engines.Clear();
 //Add Razor Engine
 ViewEngines.Engines.Add(new RazorViewEngine());
 ... 
} 

After removing all the view engines and register only Razor view engine, now MVC try to resolve a view by searching the views that match the Razor view engine's naming conventions only as shown in fig.

You can also make your custom View Engine. For help refer the article Custom Razor View Engine for C# and VB

Note

  1. After removing Web Form engine, Razor View Engine will be almost twice as fast with the Web Form engine.

  2. Use this when you are sure that you will use only Razor views. It will be helpful to you.

  3. If you are using both type of views (ASPX & Razor), don't implement this.

What do you think?

I hope you will enjoy this tricks while programming with MVC Razor. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

Share Article

Live Classes Schedule

Our learn-by-building-project method enables you to build practical/coding experience that sticks. 95% of our learners say they have confidence and remember more when they learn by building real world projects.
.NET Solution Architect Certification Training Jul 28 SAT, SUN
Filling Fast
05:30PM to 07:30PM (IST)
Get Details
Advanced Full-Stack .NET Developer Certification Training Jul 28 SAT, SUN
Filling Fast
07:00AM to 09:00AM (IST)
Get Details
ASP.NET Core Certification Training Jul 28 SAT, SUN
Filling Fast
07:00AM to 09:00AM (IST)
Get Details
ASP.NET Core Project Aug 24 SAT, SUN
Filling Fast
07:00AM to 09:00AM (IST)
Get Details

Can't find convenient schedule? Let us know

About Author
Shailendra Chauhan (Microsoft MVP, Founder & CEO at Scholarhat by DotNetTricks)

Shailendra Chauhan is the Founder and CEO at ScholarHat by DotNetTricks which is a brand when it comes to e-Learning. He provides training and consultation over an array of technologies like Cloud, .NET, Angular, React, Node, Microservices, Containers and Mobile Apps development. He has been awarded Microsoft MVP 8th time in a row (2016-2023). He has changed many lives with his writings and unique training programs. He has a number of most sought-after books to his name which has helped job aspirants in cracking tough interviews with ease.
Accept cookies & close this