Search code examples
asp.netasp.net-mvcweb-config

why are there 2 web.config files


Why are there multiple (2) web.config files:

  • 1 in the root directory
  • 1 in the views directory

Solution

  • 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.aspx and load the page outside the MVC pipeline.