Choosing a Connection String based on kind of request

微笑、不失礼 提交于 2019-12-12 01:36:51

问题


I used to have a web service through which a client could perform DB operations and a website could read the DB.

Now, due to re-design needs, through the webservice a client can make DB operations. This DB is in workstation A. Through the same webservice, a website retrieves information from DB. This DB is in workstation B.

DB in location A constantly feeds the DB in workstation B, and I need the website to display the information on workstation B.

Is there any way I can have different connection strings on the web.config (both the web service and the website share the same config file) and have the webservice use the corresponding one depending on whether its a client request or a website request ?


回答1:


Did this using

HttpContext.Current != null? ConnectionStrings["Website"].ConnectionString : ConnectionStrings["Client"].ConnectionString

and it works perfect



来源:https://stackoverflow.com/questions/3444000/choosing-a-connection-string-based-on-kind-of-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!