Working With View Engines in MVC

Dheeraj Kumar Gunti

Reading Time : ( words)

Hi All, Welcome back to knowledge Base.

In MVC we have two types of rendering engines

  • ASPX Engine
  • Razor Engine

Both are enabled by default in all MVC applications. We can enable and disable view engines based on the application type that we work.

If you see, when you run an MVC application and specify an Action for which there is no view associated then you will see the below result which inturn displays all the types of engines. If we are working with Razor then we should display only Razor Engine. Using the below code snippet we can make only Razor engine to work for our application.


This will increase in performance of our MVC application.

Fine. We have resolved one issue with respect to holding one view engine for our application. In the above error page we see .cshtml and .vbhtml extensions. But if our application is dealing with only one extension then removing other will give correct picture of execution.

Following is the code snippet which makes application to look only for one specific extension. In this example we have considered .cshtml.

In the above snippet where we have specified to use RazorEngine, we now specify our custom engine so that Application now will work on Razor engine and will take only .cshtml as file types.

Enjoy coding......