Reputation: 1740
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
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
Reputation: 190907
Yes you can. The ASP.NET MVC project templates do this to restrict browsing the Views
folder.
Upvotes: 1
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