jgauffin
jgauffin

Reputation: 101130

Two web.configs?

ASP.Net MVC applications has two web.configs. One in the root folder and one in the Views folder. Why?

Upvotes: 2

Views: 244

Answers (2)

Denis Ivin
Denis Ivin

Reputation: 5644

From Pro ASP.NET MVC 2 book:

/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 Web Forms *.aspx files). This file also contains configuration needed to make the standard ASP.NET ASPX page compiler work properly with ASP.NET MVC view syntax.

Upvotes: 2

Mariusz
Mariusz

Reputation: 1409

One reason is to simplify your views and your pages. You can put the compilation or even the masterPageFile declaration from your views in this web.config, for example. Phil Haack did a great post on this -> http://haacked.com/archive/2009/08/04/views-on-a-diet.aspx

Upvotes: 2

Related Questions