Can't read web.config

C

cssnow

I have a web service with a connection string in the appSettings of my
web.config file. The beginning of the config looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<appSettings>
<add key="ABConnectionString"
value="server=localhost;database=VueBay;uid=sa;pwd=lonewolf"/>
</appSettings>

<system.web>
....

I can run my service with the forms that ASP.NET creates by sticking
the path for my service in a browser like this:
http://localhost/ABPopulateAccountService/PopulateAccount.asmx. It
works great. I also have a test client from which I call the web
methods. It doesn't works so great. My client calls the same
service, but can't read the appSettings for some reason. When I run
the client my webservice returns strConn = null from the following
line:

string strConn = ConfigurationSettings.AppSettings["ConnectionString"];

whereas the ASP.NET forms return my connection string. It seems to me
that since they are both running the same service they ought to give me
the same result. Unfortunately, ASP.NET isn't telling me much about
what is going on when I run my client. I can remove the config file,
change the contents of it, fill it with errors and it does exactly the
same thing; it returns a null in my string. I can't even be sure
that ASP.NET is finding the web.config. I've tried moving the config
around within my directory structure. It doesn't make any difference
where it is. I've seen some others on the message boards complaining
about this, but have yet to see a definitive reason why this happens.

Any thoughts?
Rob
 
M

Martin Kulov

I've tried moving the config
around within my directory structure. It doesn't make any difference
where it is.

It seems to me that you are not changing the correct web.config file. Open
Internet Information Services Manager and see where your web service is
located at. Go to that directory and see if there is any web.config at all.
Also make sure that you have created the virtual directory of the web
service project correctly.
Since your service works in IE it should work from the client also. Make
sure you call the same web service instance. Debug your client application
and see if there are not any exceptions calling the web service.

Regards,


--
Martin Kulov
http://www.codeattest.com/blogs/martin

MCAD Charter Member
MCSD.NET Early Achiever
MCSD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top