我可以在一个单一的Web项目中的多个web.config文件中?多个、文件、项目、Web

由网友(奈奈)分享简介:我想知道我可以在我的Web项目2个或更多的web.config文件?如果是的话那么如何编译器会检查连接字符串?I wanted to know that can I have 2 or more web.config files in my web project? If yes then how the compi...

我想知道我可以在我的Web项目2个或更多的web.config文件?如果是的话那么如何编译器会检查连接字符串?

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?

推荐答案

您可以在同一级别的项目中有多个配置文件了。我们不喜欢这样。我们有一个主配置文件( Web.config中),那么我们有两个更多的配置文件。 的app.config Database.Config 。在的app.config 我们定义了所有应用程序级别设置。在 Database.Config 我们定义了所有的数据库级别设置。而在 Web.config中我们指的app.config和Database.Config是这样的:

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 and Database.Config. in App.Config we defined all the application level settings. in Database.Config we define all the database level settings. And in Web.Config we refer App.Config and Database.Config like this:

 <appSettings configSource="app.config">
 </appSettings>
 <connectionStrings configSource="database.config">
 </connectionStrings>

此外,您还可以在子目录多个web.config文件中。设置会自动asp.net被改写。

Also , you can have multiple web.config files in sub directories. Settings will be override automatically by asp.net.

阅读全文

相关推荐

最新文章