Verifying web.config

T

Tim

Hi,

In my asp.net application, I wish to double check some of the options set in
the web.config file during application startup to make sure that for example
errors are never going to be reported to the internet user and that debug is
not set to true etc.

How does one read the following values?

<system.web>
<compilation defaultLanguage="vb" debug="true" />



<customErrors mode="RemoteOnly" />



I have read through and tried many of the different ConfigurationSettings
objects etc but always get either nothing or an exception.

There are also several appSettings that are mandatory...

If I detect a show stopper setting then what do I need to do to stop the
application startup?

Thanks for any help,



- Tim
 
M

MattC

I'm presuming you are using ConfigurationSettings.GetConfig(string
sectionname).

When you detect and error you can really stop your application starting as
in order to do the checks it has already started. With appropriately placed
Exception handling you should redirect your application to a standard page
that displays a friendly error message to the user and log you error where
you see fit.

MattC
 
P

Paul Glavich [MVP ASP.NET]

You can always use just plain XPath on the web.config. The ASPNET user
obviously has access to this file, and some simple XPath statements will
return the properties you are interested in.
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top