Thursday, 18 August 2016

Why are there two web.config files in my MVC application a) 1 in the root directory b) 1 in the views directory

The settings should go into the web.config at the application root. The web.config in the views folder is there to block direct access to the view aspx pages which should only get served through controllers.

OR,

The web.config in the Views directory just has one significant entry, which blocks direct access:
<add path="*" verb="*"
      type="System.Web.HttpNotFoundHandler"/>
This is so someone cannot manually try to go to http://www.yoursite.com/views/main/index.aspxand load the page outside the MVC pipeline.

OR,
/Views/Web.config
This is not your application’s main web.config file. It just contains a directive instructing the web server not to serve any *.aspx files under /Views (because they should be rendered by a controller, not invoked directly like classic WebForms *.aspx files). This file also contains configuration needed to make the standard ASP.NET ASPX page compiler work properly with ASP.NET MVC view template syntax.
/Web.config
This defines your application configuration.
This is from the book Pro ASP.NET MVC Framework

No comments:

Post a Comment