分享多个Web项目之间的连接字符串 [英] Share a Connection string between multiple web projects
问题描述
OK我有两个Web项目WebProject1&安培; WebProject2。这都需要数据库连接,所以这是所有常见的叫一个C#.NET项目。
OK I have two web projects WebProject1 & WebProject2. Both require database connectivity so this is all in a C#.NET project called Common.
现在我的问题是目前双方的连接字符串是相同的,目前很难coded到DB类(在共同的项目),但我想将其移动到一个配置文件。
Now my question is currently the connection string for both is the same and at the moment it's hard coded into the DB class (In the Common project), but I want to move it out to a config file.
我真的很想有与连接字符串,其中两个Web项目,然后使用通用项目配置文件。这是可能的,如果又如何?
I would really like to have a config file in the Common project with the connection string in which both web projects then use. Is this possible, and if so how?
推荐答案
有是你能做到这一点的几个方面:
There's a few ways you could do it:
这篇关于分享多个Web项目之间的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!