Search code examples
c#web-servicesweb-config

WebService doesn't read web.config


I've got 3 connectionstrings in web.config, and I used theirs like this:

using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SomeName"].ConnectionString))

Every metgod is called by winforms application.

One of webmethods doesn't work properly because it reads only one connectionString:

data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

It's not a connectionString from my web.config .

I invoke every method in the same way.

How it's impossible ??

EDITED:

I use facade: This is structure: WinForms calls WebMethod SaveItem SaveItem calls method on Facade: SaveItemAndDoDatabaseStuff SaveItemAndDoDatabaseStuff does database stuff.


Solution

  • We can't see your web structure, but is it possible that your app isn't configured as an application in IIS, therefore is picking up the master web.config? Which would look exactly like that...

    Go into IIS and ensure it is an application (it may have a cog icon).