What does the Web.Config file do in the views folder of a MVC project

No, you do not need to configure a virtual folder because of this extra web.config file.

The web.config file exists in the Views folders to prevent access to your views by any means other than your controller. In the MVC design pattern, controllers are supposed to route requests and return a rendered view to the calling client.

In other words, your view at www.mydomain.com/MySuperController/AwesomeAction1/SweetPage.aspx should not be directly accessible.

If you peek at the web.config file it actually registers the HttpNotFoundHandler to all paths and verbs:

<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>

Or, in IIS 7 it might look like

<add name="BlockViewHandler" path="*.aspx" verb="*" 
    preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>

Leave a Comment