I wanted to know that can I have 2 or more web.config files in my web project? If yes then how the compiler will check the connection string?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- Generic Generics in Managed C++
- How to store image outside of the website's ro
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
You can have one for the entire website configuration (framework that you are using, additional dependencies , etc.) in the root project. You can also have another web.config files in sub directories. this one is usually used to provide access rules for each folder, like the "Admin" folder can only be accessed for users in admin role...
If you want to have multiples websites configuration you must create multiples "applications" , this way each one must have its web.config file.
You can have multiple configuration files in your project at the same level too. We do it like this. We have one main configuration file (
Web.Config
), then we have two more configurations files.App.Config
andDatabase.Config
. inApp.Config
we defined all the application level settings. inDatabase.Config
we define all the database level settings. And inWeb.Config
we refer App.Config and Database.Config like this:Also , you can have multiple web.config files in sub directories. Settings will be override automatically by asp.net.
Yes you can have two web.config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration.
For example if you have a application which has two modules lets say accounts and sales. You will create both these modules in a separate folder with each folder having separate config files.
Please do watch this facebook video which explains the same in a very demonstrative manner. Click here to watch , why do we need 2 web.config files in a application