Gautam
Gautam

Reputation: 1740

c# multiple web.config files in a single project under different folders?

Can we have multiple web.config files in a single project in c#? if yes then what is its benefit? Say I have a project ABC that has three folders under it. Now ABC has its web.config file, so does each folder under ABC. so there are total 4 web.config files. So what will be the output when I run the project?

Upvotes: 1

Views: 1973

Answers (3)

Mark
Mark

Reputation: 1537

Yes you can have multiple web.config files in the separate folders. They can be used to enable/disable modules on a per folder basis. You can even set up each of those folders as separate web sites, even sub-sites, that use some modules from the parent web.config and some from the sub-site web.config.

I wrote up a blog post in the past about using BlogEngine.NET as the main site and configuring the web.config file in sub-sites. It might be of some help to you: http://markschlegel.com/post/2011/11/26/BlogEngineNET-a-sub-site!.aspx

Upvotes: 3

Daniel A. White
Daniel A. White

Reputation: 190907

Yes you can. The ASP.NET MVC project templates do this to restrict browsing the Views folder.

Upvotes: 1

j0aqu1n
j0aqu1n

Reputation: 1021

Sure you can. An example of what this is used for is the default MVC 3 project template. There is one web.config for the site, and there is one inside the Views folder to deal with rendering the views.

Upvotes: 2

Related Questions