在解决方案中仅使用一个web.config文件或指向多个项目中的一个web.config文件 [英] using only one web.config file or pointing to one web.config file from multiple projects in a solution

查看:143
本文介绍了在解决方案中仅使用一个web.config文件或指向多个项目中的一个web.config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个解决方案,在此解决方案下有4个Web服务项目.它们每个都有自己的单独的web.config文件.但是,我只有一个数据访问层,并且连接字符串位于此项目的web.config文件中.我希望所有项目都使用此项目的web.config文件.我不想在每个项目的web.config文件中定义相同的连接字符串.我该怎么办?

问候,

Hi
I have a solution and under this solution there are 4 web service projects. Each of them has a separate web.config file of its own. However I have only one data access layer and connection string is in this project''s web.config file. I would like all the projects use this projects web.config file. I do not want to define the same connection string in every project''s web.config file. How do I do that?

Regards,

推荐答案

在部署时,您可以使用配置继承

http://msdn.microsoft.com/en-us/library/ms178685.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/dtbwsx8s%28v = vs.71%29.aspx [ ^ ]

您必须以某种方式构建网站,才能使继承生效

例如

At deployment time, you can use configuration inheritance

http://msdn.microsoft.com/en-us/library/ms178685.aspx[^]

http://msdn.microsoft.com/en-us/library/dtbwsx8s%28v=vs.71%29.aspx[^]

You would have to structure your site in a certain way in order for the inheritance to come into effect

e.g

Application Root
Web.config
----Service1
----Service2
----Service3
----Service4



如果创建了虚拟目录并将web.config放置在该根文件夹中,则从该根目录创建虚拟目录-它们将继承应用程序根目录中定义的设置



If you created a virtual directory and placed your web.config in that root folder, then create virtual directories from the root directory - they would inherit the settings defined in application root


这篇关于在解决方案中仅使用一个web.config文件或指向多个项目中的一个web.config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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