ASP. NET MVC provides two view engines by default, namely: Webformviewengine and Razorviewengine. When MVC finds views, it finds them in the order specified. When our MVC program does not find the appropriate view, the following error message appears in the page:
It is known that the WebForm view engine is the first to perform the search, followed by the Razor view engine. In our MVC project, we usually use only one of the razor or webform (most of them are razor). If we only use razor in our project, it would be superfluous to perform the WebForm view engine lookup in this case. That being the case, we can avoid this extra action by removing the WebForm view engine (more or less to improve performance). The removal operation is simple, just add the following code to the Application_Start () function in the Global.asax file:
protected void Application_Start () { // omit other code in function // Clear all View engines ViewEngines.Engines.Clear (); // ViewEngines.Engines.Add (new razorviewengine ());}
Now we run our MVC program again, and when the corresponding view is not found, the error message in the page is as follows:
As the diagram shows, Webformviewengine has been successfully removed, so the program does not have to look for webformviewengine related views.
ASP. NET MVC removal of unused view engines