Creating a Web.config Editor - Part 1
page 3 of 5
by Jason N. Gaylord
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 26044/ 39

Section 1: Opening The Web.Config File
Let’s begin by first opening up a default web.config file. Usually, your default web.config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
                Set compilation debug="true" to insert 
                debugging symbols (.pdb information)
                into the compiled page. Because this 
                creates a larger file that executes more 
                slowly, you should set this value to 
                true only when debugging and to false 
                at all other times. For more information, 
                refer to the documentation about 
                debugging ASP.NET files.    
          <compilation defaultLanguage="vb" debug="true" />
                Set customErrors mode="On" or "RemoteOnly" 
                to enable custom error messages, "Off" to 
                disable. Add <error> tags for each of the 
                errors you want to handle.
          <customErrors mode="RemoteOnly" />
          <!--  AUTHENTICATION 
                This section sets the authentication 
                policies of the application. Possible 
                modes are "Windows", "Forms", "Passport" 
                and "None"
          <authentication mode="Windows" />
          <!--  AUTHORIZATION
                This section sets the authorization 
                policies of the application. You can 
                allow or deny access to application 
                resources by user or role. Wildcards: "*"
                mean everyone, "?" means anonymous 
                (unauthenticated) users.
              <allow users="*" />
              <!-- Allow all users -->
              <!--  <allow  users="[comma separated 
                    list of users]" 
                    roles="[comma separated list 
                    of roles]"/>
                    <deny users="[comma separated list 
                    of users]" roles="[comma separated 
                    list of roles]"/>
                Application-level tracing enables trace 
                log output for every page within an 
                application. Set trace enabled="true"
                to enable application trace logging. If 
                pageOutput="true", the trace information 
                will be displayed at the bottom of each 
                page. Otherwise, you can view the 
                application trace log by browsing the 
                "trace.axd" page from your web 
                application root.
          <trace enabled="false" requestLimit="10" 
              pageOutput="false" traceMode="SortByTime"
              localOnly="true" />
                By default ASP.NET uses cookies to 
                identify which requests belong to a 
                particular session. If cookies are not 
                available, a session can be tracked by 
                adding a session identifier to the URL. 
                To disable cookies, set sessionState 
          <sessionState mode="InProc" 
              sqlConnectionString="data source=;
              user id=sa;password=" cookieless="false" 
              timeout="20" />
          <!--  GLOBALIZATION
                This section sets the globalization 
                settings of the application.
          <globalization requestEncoding="utf-8" 
              responseEncoding="utf-8" />

Notice how this file has a few different node levels. The first level is the <configuration> node. The second node is the <system.web> node. So, we have to pass by the first two node levels to get to the "good stuff" in the third level.

View Entire Article

User Comments

Title: I Have question   
Date: 2006-05-08 2:25:38 AM
How to use Location Tag in web.config file?
and .......... Thanks !!!
Title: Excellent trial for NewToXml   
Name: Baljeet Kiroriwal
Date: 2006-03-02 7:46:07 AM
Good Article n gr8 information
Title: What if the solution is in a source safe   
Name: m7e7
Date: 2004-08-05 4:03:37 PM
What if the soln is in a source safe vault?
Title: The problems I had   
Name: Sergio Florez
Date: 2004-07-23 9:51:21 AM
First, sorry if I mix up the first and second part of the article but here goes:

You're capturing the return of SelectSingleNode() in an XmlAttribute and that didn't work for me. It said it needed a NodeSet. I fixed this by capturing it with an XmlNode and working with its Attributes collection.

The other problem I had was that your XPath didn't capture the node for me so I had to use this:
Title: RE: Thanks but no thanks   
Name: Jason
Date: 2004-07-22 4:35:10 PM
I wish you'd let me know what isn't working. This way I can provide some "troubleshooting" for you.
Title: Thanks but no thanks   
Name: Sergio Florez
Date: 2004-07-22 11:31:08 AM
This article's basic concept of trying to modify the web.config is great, unfortunately the code doesn't work for me. Maybe you should try and write some troubleshooting for this.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2023  |  Page Processed at 2023-12-09 7:54:06 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search