To facilitate the configuration of the web. config file, I wrote a common example of the web. config file, which can be modified as needed.
Three shortcut methods for creating a web. config file:
1. Use Asp.net website Configuration tool in vs2005 to configure
2. Compile the machine. config file in the c: \ windows \ Microsoft. NET \ framework \ v2.0.50727 (. NET Framework Version) \ config \ directory.
3. Modify the following file as a template
Click here to expand the code
<? XML version = "1.0" encoding = "UTF-8" ?>
<! --
Note: In addition to manually editing this file, you can also use
Web management tools to configure application settings. You can use
"Website"-> "ASP. NET configuration" option.
The complete list of settings and comments is displayed in
In machine. config. Comments, this file is usually located in
\ Windows \ Microsoft. NET \ framework \ v2.x \ config
-->
< Configuration Xmlns = "Http://schemas.microsoft.com/.NetConfiguration/v2.0" >
< Appsettings >
<! -- Enable data caching -->
< Add Key = "Enablecaching" Value = "True" />
</ Appsettings >
< Connectionstrings >
< Add Name = "Strconnuserdb"
Connectionstring = "Data Source =.; initial catalog = profile1; Integrated Security = true"
Providername = "System. Data. sqlclient" />
</ Connectionstrings >
< System . Web >
< Membership >
< Providers >
< Remove Name = "Aspnetsqlmembershipprovider" />
< Add Name = "Aspnetsqlmembershipprovider"
Type = "System. Web. Security. sqlmembershipprovider, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"
Connectionstringname = "Strconnuserdb"
Enablepasswordretrieval = "False"
Enablepasswordreset = "True"
Requiresquestionandanswer = "True"
Applicationname = "/"
Requiresuniqueemail = "False"
Passwordformat = "Hashed"
Maxinvalidpasswordattempts = "5"
Minrequiredpasswordlength = "7"
Minrequirednonalphanumericcharacters = "1"
Passwordattemptwindow = "10"
Passwordstrengthregularexpression = ""
Description = "Store membership data"
/>
</ Providers >
</ Membership >
< Profile Enabled = "True" Defaultprovider = "Aspnetsqlprofileprovider" Inherits = "" >
< Providers >
< Remove Name = "Aspnetsqlprofileprovider" />
< Add Name = "Aspnetsqlprofileprovider"
Connectionstringname = "Strconnuserdb"
Applicationname = "/"
Type = "System. Web. profile. sqlprofileprovider, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"
Description = "Store profile data"
/>
</ Providers >
< Properties >
< Add Name = "Name" />
< Add Name = "Backcolor" Type = "System. Drawing. Color" Allowanonymous = "True" Serializeas = "Binary" />
</ Properties >
</ Profile >
< Rolemanager Enabled = "True" Cacherolesincookie = "True" >
< Providers >
< Remove Name = "Aspnetsqlroleprovider" />
< Add Name = "Aspnetsqlroleprovider"
Connectionstringname = "Strconnuserdb"
Applicationname = "/"
Type = "System. Web. Security. sqlroleprovider, system. Web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a"
Description = "Store role data"
/>
</ Providers >
</ Rolemanager >
<! -- Other rolemanager attributes (and their defaults) include:
Cookiename = ". aspxroles"
Cookietimeout = "30"
Cookiepath = "/"
Cookierequiressl = "false"
Cookieslidingexpiration = "true" // renew expiring cookies?
Createpersistentcookie = "false" // issue persistent cookie?
Cookieprotection = "all"/> // cookie Protection Level
-->
< Compilation Debug = "False" />
< Authentication Mode = "Forms" />
<! --
<Anonymousidentification
Enabled = "true"
Cookiename = ". aspxanonymous"
Cookietimeout = "43200"
Cookiepath = "/"
Cookierequiressl = "false"
Cookieslidingexpiration = "true"
Cookieprotection = "all"
Cookieless = "usecookies"
/>
-->
<! --
<Customerrors mode = "remoteonly" defaultredirect = "genericerrorpage.htm">
<Error statuscode = "403" Redirect = "noaccess.htm"/>
<Error statuscode = "404" Redirect = "filenotfound.htm"/>
</Customerrors>
-->
</ System. Web >
< Location Path = "User" >
< System . Web >
< Authorization >
< Allow Roles = "? " />
< Deny Users = "*" />
</ Authorization >
</ System. Web >
</ Location >
</ Configuration >