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

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:
Web.Config
**************************************************

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
      <system.web>
          <!--  DYNAMIC DEBUG COMPILATION
                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" />
          
          <!--  CUSTOM ERROR MESSAGES
                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.
          -->
          
          <authorization>
              <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]"/>
              -->     
          </authorization>
          
          <!--  APPLICATION-LEVEL TRACE LOGGING
                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" />
              
          <!--  SESSION STATE SETTINGS
                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 
                cookieless="true".
          -->
          
          <sessionState mode="InProc" 
              stateConnectionString="tcpip=127.0.0.1:42424"
              sqlConnectionString="data source=127.0.0.1;
              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" />
      </system.web>
</configuration>

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   
Name: OMAR ALZOBAIDI
Date: 2006-05-08 2:25:38 AM
Comment:
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
Comment:
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
Comment:
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
Comment:
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:
"descendant::appSettings/add[@key='conServer']"
Title: RE: Thanks but no thanks   
Name: Jason
Date: 2004-07-22 4:35:10 PM
Comment:
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
Comment:
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-2022 ASPAlliance.com  |  Page Processed at 2022-09-24 3:25:23 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search