web.config

D

Dan

I am trying to add a definition for ConnString to web.config as follows
(VB.NET STD 2003)

<configuration>
<system.web>
..........
<appsettings>
<add key="ConnString" value="C:\test\test.mdb" />
</appsettings>

</system.web>
</configuration>

When I try to run it, I get "Error while trying to run project: Unable to
start debugging on web server. Server side error occurred on sending debug
HTTP request."

I have tried relocating the entry inside the <system.web> tags with the same
result.

What am I doing wrong? Thanks.
 
P

Pete Wright

This error doesn't actually have anything to do with web.config. There are
number of reasons why this could happen, but the most common I see on my
machines is that I have betas of Web Developer Express or Visual Studio.NEt
2005 on the machine. These cause the app to run as a .NET 2.0 app. *IF* this
is the case, download Denis Bauer's excellent ASP.NET version switcher from
http://www.denisbauer.com/NETTools/ASPNETVersionSwitcher.aspx&e=9901. Then
run it, point it at your application and switch it back into .NET 1.1
instead of .NET 2.

If you aren't use a .NET 2.0 beta anywhere on the machine take a look at
http://support.microsoft.com/default.aspx?scid=kb;en-us;306172. This
describes common error messages and how to resolve them with .NET.

Finally, the settings you posted for your web.config indicate that you want
your application to access a local file at runtime. SInce this is a web
application, make sure that the web application user has access rights to
that file or you will find that you will next get a security violation error
thrown when you do resolve the problem.

Hope that helps,
 
D

Dan

I don't have NET 2 on the machine. I haven't used the "file" attribute in
the appsettings code so why would it think that I am referring to an
external file? The error comes up before the appsetting is accessed by vb
code. when I try to debug start---There are no compile errors.

The KB article says that this error arises from a syntax error in the
web.config file. If I remove the three lines from the web.config file, the
problem goes away.

It doesn't matter what I use as the key name or the value. If those lines
are present the rror is tripped.
 
N

Nick Malik [Microsoft]

Hello Dan,

You definitely provided more information in that response. You also appear
to be a bit unhappy with Pete's response. He's only trying to help.

First off, the App Settings section appears under the configuration tags,
not within the system.web child:

<configuration>
<system.web>
...
</system.web>
<appSettings>
<add key="somekey" value="somevalue" />
</appSettings>
</configuration>

Next, XML is case sensitive. It is not an <appsettings> section. it is an
<appSettings> section.

This is probably your problem.

For further info, this article is often useful:
http://samples.gotdotnet.com/quickstart/aspplus/doc/configretrieve.aspx

Also, the reason that Pete assumed that you are accessing a file is because
the CONTENT of the config app setting that you posted was a filename. He
was hoping to help you out of the next issue you may face: the fact that
ASP.NET applications do not normally have access to file system resources.

I hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
D

Dan

Sorry to say, that solution resulted in the same error message. Here is the
code I have copies from web.config

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


<appSettings>

<addkey key="connstr" value="something" />

</appSettings>


</configuration>

Any other clues would be appreciated.

Thanks, Dan
 
N

Nick Malik [Microsoft]

Hi Dan,

The schema for config files is set by .Net. The tags are very specific.

The tag you need is not "addkey" but rather "add"
so <addkey key="connstr" value="something" />
becomes <add key="connstr" value="something" />

HTH
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

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

Top