问题
I have two websites running on the same Windows 2008r2 64bit server, SQL Server Web edition. Both sites are identical with just the connection string pulling the data from a different database.
Both sites are running in different application pools - both .net 2, classic pipeline, 32bit - and the website is quite old being developed back in 2005. Most of the data access is in compiled dll's in the bin directory.
If I print out the connection string I'm using by calling ConfigurationManager.ConnectionStrings["name"].ConnectionString I get the correct connection string which is stored in the web.config file.
However if I print out the connection string from the data access component I get the connection string from the other copy of the website. This connection string is only set in the other websites web.config file - nowhere in this website.
How can ASP.Net be accessing a connection string from a different website in a different process? I'm lost as to what either the source or solution to this issue is, it seems bazaar.
Many thanks for any ideas. Both sites works perfectly side by side on Windows 2003 server.
回答1:
Have you checked by going in
IIS7 -> Sites -> YOUE_WEB_SITE -> Connection String
Or
ConfigurationManager.AppSettings.Get("name")
回答2:
This issue has now been resolved by changing the connection string key on one of the websites. Still unsure why it happened at all but its as though the connection strings with same name are being shared between to websites on the same server in different application pools. Many thanks for the help.
来源:https://stackoverflow.com/questions/9923418/iis7-pulling-wrong-connection-string-cross-site-and-process