Web.config not being read.

  • Thread starter Thread starter Chris V
  • Start date Start date
C

Chris V

I'm having a problem deploying my ASP.NET application to a WIN2k server.
(IIS5 .NET 1.1)

When I try to access ConfigurationSettings.AppSettings("WhateverValue") I
get an "Object reference not set to an instance of an object." message

I thought this may have been to do with Virtual Directory settings but I've
got the folder set as an application in IIS and asp.net is installed and
working. My web.config file is Not Marked read-only and I can't see any
other problems with the setup. pages that do not attempt to read settings
from the web.config work correctly.

Has anyone else come across this problem, and if so, how did you fix it?

best regards,

Chris.
 
Have you put your <appSettings></appSettings> outside of the <system.web>

<configuration>

<appSettings>
<add key="WhateverValue" value="1234" />
</appSettings>

<system.web>
...
</system.web>
</configuration>

Also web.config is case sensitive, but I don't think that matters as far as
attribute values.

HTH,
--Michael
 
Hi Michael,

Yes. My web.config file is configured correctly.

It's one of these horrible situations my app works on a different machine
that appears to be configured identicaly. The differences may be a result of
the fact that I have Visual Studio installed on my development machine but
not on the server I'm deploying to.

cheers,

Chris.
 
Not sure. Do you have a single web.config file on the whole site ? Perhaps
another one could be read instead ? If you change some other setting in this
file is it taken into account ?

--
 
When I try to access ConfigurationSettings.AppSettings("WhateverValue") I
get an "Object reference not set to an instance of an object." message

It's one of these horrible situations my app works on a different machine
that appears to be configured identicaly. The differences may be a result of
the fact that I have Visual Studio installed on my development machine but
not on the server I'm deploying to.

Compare your machine.config files for the different machines. They should
both have these sections:

<configuration>
<configSections>
<section name="appSettings"
type="System.Configuration.NameValueFileSectionHandler, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
</configuration>

If one of them doesn't or they differ, try fixing it for the machine that is
giving you trouble.

Martin.
 
Back
Top