我可以在一个单一的Web项目中的多个web.config文件中? [英] Can I have multiple web.config files in a single web project?

查看:271
本文介绍了我可以在一个单一的Web项目中的多个web.config文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我可以在我的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.

这篇关于我可以在一个单一的Web项目中的多个web.config文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆