Web.config (Application configuration information) Summary _ Practical Tips

Source: Internet
Author: User
Tags anonymous configuration settings http cookie parent directory connectionstrings
The Web.config file is an XML text file that stores configuration information for ASP.net Web applications (such as the most common settings asp.net the way the Web application is authenticated) and can appear in every directory in the application. When you pass. NET when you create a new Web application, by default, a default Web.config file is created automatically in the root directory, including the default configuration settings, and all subdirectories inherit its configuration settings. If you want to modify the configuration settings for subdirectories, you can create a new Web.config file in the subdirectory. It can provide configuration information in addition to the configuration information inherited from the parent directory, or you can override or modify the settings defined in the parent directory.

Modifications to the Web.config file at run time do not require a restart of the service to take effect (note: section exceptions). Of course, Web.config files can be extended. You can customize the new configuration parameters and write configuration section handlers to process them.
Copy Code code as follows:

<?xml version= "1.0"?>
<configuration>
<!--specify configuration sections and namespace declarations. Clear: Removes all references to inherited sections and section groups, allowing only sections and section groups that are added by the current section and sectiongroup elements. Remove: Removes a reference to an inherited section and section group. Section: Defines the association between a configuration node handler and a configuration element. Sectiongroup: Defines an association between a configuration section handler and a configuration section. -->
<configSections>
<sectiongroup name= "system.web.extensions" type= "System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, version=1.0.61025.0, culture=neutral, publickeytoken=31bf3856ad364e35 ">
<sectiongroup name= "scripting" type= "System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, version=1.0.61025.0, Culture=neutral, publickeytoken=31bf3856ad364e35 ">
<section name= "scriptResourceHandler" type= "System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, version=1.0.61025.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "requirepermission=" False "allowdefinition=" MachineToApplication "/>
</sectionGroup>
</sectionGroup>
<section name= "Rewriter" type= "Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.urlrewriter "/>
</configSections>
<!--appsettings is an application setting that can define information such as global constant settings for an application. -->
<appSettings>
<add key= "Errpage" value= "http://www.cnblogs.com"/>
</appSettings>
<!--connection string settings-->
<connectionStrings>
<add name= "sqlConnectionString" connectionstring= ""/>
</connectionStrings>
<!--specify resources that apply child configuration settings and lock configuration settings to prevent them from being overwritten by quilt profiles. path Specifies resources that apply the configuration settings that are included. AllowOverride whether to allow configuration file overrides to improve the security of the configuration file. -->
<location path= "default.aspx" allowoverride= "false" >
<!--control the behavior of asp.net at runtime-->
<system.web>
<!--identity control authentication identification for a Web application .-->
<identity impersonate= "false"/>
The <!--identifies page-specific configuration settings, such as whether session state is enabled, view state, whether user input is detected, and so on. <pages> can be declared at the computer, site, application, and subdirectory levels.
MasterPageFile: The default home page is index.
Theme: The subject is default.
Buffer: Specifies whether the URL resource uses response buffering. The default value is True.
enableViewStateMac: Specifies whether ASP.net should run the message authentication Code (MAC) on the page's view state when the page is sent back from the client. If True, the encrypted view state is checked to verify that the view state has been tampered with on the client. The default value is True.
ValidateRequest: Instructs ASP.net to check for potentially dangerous data in all content entered from the browser. If True, request validation is performed by comparing all input data to a list of potentially dangerous values. If a match occurs, ASP.net throws a HttpRequestValidationException exception. The default value is True.
EnableViewState: Specifies whether view state is enabled and persisted between multiple page requests. The default value is True. -->
<pages masterpagefile= "Index" theme= "Default" buffer= "true" enableviewstatemac= "true" validaterequest= "false" Enableviewstate= "false" >
<!--controls element defines the collection of register directives and namespaces where the tag prefix is located-->
<controls></controls>
<!--collection of import directives that will be used during assembly precompilation-->
<namespaces></namespaces>
</pages>
<!--default error page settings.
Mode: With On,off,remoteonly 3 states. On indicates that the custom information is always displayed; off indicates that verbose asp.net error messages are always displayed; RemoteOnly indicates that custom information is displayed only for users who are not running on the local Web server.
defaultredirect: The URL address for redirection when an error occurs. -->
<customerrors defaultredirect= "err.html" mode= "RemoteOnly" >
< error!--Special code number--> from the directed file
<error statuscode= "403" redirect= "noaccess.htm"/>
<error statuscode= "404" redirect= "filenotfound.htm"/>
</customErrors>
<!--configuration debugging and tracing.
Enabled: Whether tracing is enabled for the application. The default value is False.
Localonly: Specifies whether the trace viewer (Trace.axd) is used only for the host Web server. If False, the trace viewer is available for any computer. By default, the Trace.axd Viewer is added to the httphandlers element. The default value is true.
Pageoutput: Specifies whether the trace output is rendered at the end of each page. If False, trace output can only be accessed through the trace utility. The default value is False.
Requestlimit: Specifies the number of trace requests stored on the server. If the limit is reached and the MostRecent attribute is false, tracing is automatically disabled. The maximum request limit is 10,000. If a value greater than 10,000 is specified, ASP.net rounds it down to 10,000 without any hint. The default value is 10.
TraceMode: Specifies the order in which trace information is displayed. The TraceMode attribute can be one of the following possible values.
Value Description
SORTBYCATEGORY Specifies that trace information be displayed alphabetically according to user-defined categories. SORTBYTIME Specifies that trace information be displayed in the order in which trace information is processed.
The default value is SortByTime. -->
<trace enabled= "true" localonly= "false" pageoutput= "true" requestlimit= "" tracemode= "SortByCategory"/>
<!--Set compilation debug= "True" to insert debug symbols into the compiled page. However, because this can affect performance, this value is set to true only during the development process. Sets the default development language C #. Batch whether batch processing is supported-->
<compilation debug= "true" defaultlanguage= "C #" batch= "false" >
<assemblies>
<!--plus assembly references, each adding an assembly means that your application already relies on an assembly, and you can use--> in your application
<add assembly= "System.Web.Extensions, version=1.0.61025.0, culture=neutral, publickeytoken=31bf3856ad364e35"/ >
<add assembly= "System.Design, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/>
<add assembly= "System.Web.Extensions.Design, version=1.0.61025.0, Culture=neutral, publickeytoken= 31bf3856ad364e35 "/>
<add assembly= "System.Windows.Forms, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/>
<add assembly= "system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/>
<add assembly= "System, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/>
<add assembly= "System.Xml, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/>
<add assembly= "System.Drawing, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/>
<add assembly= "System.Data, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089"/>
<add assembly= "System.Web.Services, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/>
<add assembly= "System.Configuration, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a"/>
</assemblies>
<!--defines a collection of build providers that are used to compile custom resource files. -->
<buildProviders>
<add extension= ". aspx" type= "System.Web.Compilation.PageBuildProvider"/>
<add extension= ". ascx" type= "System.Web.Compilation.UserControlBuildProvider"/>
<add extension= ". Master" type= "System.Web.Compilation.MasterPageBuildProvider"/>
<add extension= ". asmx" type= "System.Web.Compilation.WebServiceBuildProvider"/>
<add extension= ". ashx" type= "System.Web.Compilation.WebHandlerBuildProvider"/>
<add extension= ". Soap" type= "System.Web.Compilation.WebServiceBuildProvider"/>
<add extension= ". resx" type= "System.Web.Compilation.ResXBuildProvider"/>
<add extension= ". Resources" type= "System.Web.Compilation.ResourcesBuildProvider"/>
<add extension= ". wsdl" type= "System.Web.Compilation.WsdlBuildProvider"/>
<add extension= ". xsd" type= "System.Web.Compilation.XsdBuildProvider"/>
<add extension= ". rdlc" Type= "Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, version= 8.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a "/>
</buildProviders>
</compilation>
<!--the security authentication mode used by ASP.net can be configured to identify incoming users through the <authentication> section. Windows: Use the IIS authentication method. Forms: Use forms-based authentication. Passport: Use Passport cookie authentication mode. None: Do not use any authentication method. -->
<authentication mode= "Forms" >
<!--name: Specifies the name of the HTTP cookie that completes the authentication.
Loginurl: If the page URL is not validated or redirected after timeout, it is generally a login page, allowing the user to log in again.
Protection: Specifies how cookie data is protected. Can be set to: All means encrypt data, and validation is done in two ways, none means no protection cookie,encryption means to encrypt the contents of the cookie, validation indicates that the content of the cookie is validated.
TimeOut: Specifies the expiration time of the cookie. Log on again after the timeout. -->
<forms name= ". Aspxuserdemo "loginurl=" Login.aspx "protection=" All "timeout="/>
</authentication>
<!--controls Client access to URL resources, such as allowing anonymous user access. This element can be declared at any level (computer, site, application, subdirectory, or page). Must be used in conjunction with the <authentication> section. This means that anonymous users are not authenticated. Deny User weipeng-->
<authorization>
<allow users= "*"/>
<deny users= "Weipeng"/>
<allow users= "AA" roles= "AA"/>
</authorization>
<!--site globalization settings, requestencoding: It is used to check the encoding each request is sent to. ResponseEncoding: Used to check the response content encoding of the postback. fileencoding: Used to check the default encoding for file resolution such as ASPX,ASAX, the default encoding is utf-8-->
<globalization requestencoding= "gb2312" responseencoding= "gb2312" fileencoding= "gb2312"/>
<!--session state settings.
Mode: It is divided into several off,inproc,stateserver,sqlserver states. mode = "InProc" is stored in the process, featuring the best performance, the fastest, but not shared across multiple servers. mode = "StateServer" stored in the State Server feature: Use this method when you need to maintain user session information across servers. But the information is stored on the state server, and once the state server fails, the information is lost. mode= "SQL Server" is stored in SQL Server features: workloads can become larger, but information is not lost.
stateConnectionString: Specifies the name of the server where the ASP.net application stores the remote session state, which defaults to native.
sqlConnectionString: When using the session-state database, set the connection string here.
Cookieless: When set to flase, it means using cookie session state to identify the customer.
Timeout: Represents the session timeout. -->
<sessionstate mode= "InProc" stateconnectionstring= tcpip=127.0.0.1:42424 "sqlconnectionstring=" Data source= 127.0.0.1; Trusted_connection=yes "cookieless=" false "timeout=" ></sessionState>
<!--The view state settings for the asp.net application Configuration page. Sets the number of items to store in the page history. -->
<sessionpagestate historysize= "9"/>
<!--Configure the settings for the ASP.net http runtime. You can declare the maximum number of requests at the computer, site, application, and subdirectory levels at 100, the maximum allowable execution request time is 80 seconds, control the user upload file size, the default is 4M. useFullyQualifiedRedirectUrl client redirection does not need to be automatically converted to fully qualified format. -->
<!--httpmodules to configure HTTP modules within an application. -->
<add name= "OutputCache" type= "System.Web.Caching.OutputCacheModule"/>
<add name= "Session" type= "System.Web.SessionState.SessionStateModule"/>
<add name= "windowsauthentication" type= "System.Web.Security.WindowsAuthenticationModule"/>
<add name= "FormsAuthentication" type= "System.Web.Security.FormsAuthenticationModule"/>
<add name= "passportauthentication" type= "System.Web.Security.PassportAuthenticationModule"/>
<add name= "rolemanager" type= "System.Web.Security.RoleManagerModule"/>
<add name= "urlauthorization" type= "System.Web.Security.UrlAuthorizationModule"/>
<add name= "fileauthorization" type= "System.Web.Security.FileAuthorizationModule"/>
<add name= "anonymousidentification" type= "System.Web.Security.AnonymousIdentificationModule"/>
<!--custom URL rewrite, type is basically the DLL name-->
<add name= "Urlrewriter" type= "Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.urlrewriter"/>
<add name= "Profile" type= "System.Web.Profile.ProfileModule"/>
<!--httphandlers is used to give the user's request to the appropriate handler based on the URL and HTTP predicate requested by the user. This node can be configured at any level of the configuration level, that is, special handling of special files specified in a particular directory.
Add: Specifies the predicate/path mapped to the handler.
Clear: Removes all handler mappings that are currently configured or inherited.
Remove: Removes the predicate/path that is mapped to the handler. The remove instruction must exactly match the predicate/path combination of the previous add instruction. The directive does not support wildcard characters. -->
<remove verb= "*" path= "*.asmx"/>
<add verb= "*" path= "*.asmx" validate= "false" Type= "System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, version=1.0.61025.0, culture=neutral, publickeytoken=31bf3856ad364e35 "/>
<add verb= "*" path= "*_appservice.axd" validate= "false" Type= "System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, version=1.0.61025.0, culture=neutral, publickeytoken=31bf3856ad364e35 "/>
<add verb= "Get,head" path= ScriptResource.axd "type=" System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, version=1.0.61025.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "validate=" false "/ >
<add verb= "Post,get" path= "Ajaxpro/*.ashx" type= "ajaxpro.ajaxhandlerfactory, ajaxpro.2"/>
<!--Cookie Configuration properties that are used for WEB applications.
Domain: Set the Cookie domain name.
Httponlycookies: Enables the output of httponlycookies cookies in Internet Explorer 6 SP1. The default value is False.
requireSSL: Gets a value indicating whether Secure Sockets Layer (SSL) traffic is required .-->
<!--control the behavior of the ASP.net Web service and its clients.
Protocols: Specifies the transport protocol that asp.net can use to decrypt the http-->
<webServices>
<protocols>
<add/>
</protocols>
</webServices>
<!--Configure cache settings for the WEB application.
Cache: Defines global application cache settings.
OutputCache: Specifies application-scoped output-cache settings.
outputCacheSettings: Specifies the output cache settings that can be applied to pages in the application.
SqlCacheDependency: Configures the SQL cache dependencies for the ASP.net application. -->
<caching>
<cache disablememorycollection = "false" Disableexpiration = "false" privateBytesLimit = "0" percentagePhysicalMemoryUsedLimit = "Privatebytespolltime" = "00:02:00"/>
<!--design a page that needs to be cached in this way, you need to add the following directive to the page: <%@ OutputCache cacheprofile= "Serveronly"%>-->
<outputCacheSettings>
<outputCacheProfiles>
<add name= "serveronly duration=" varybycustom= "browser" location= "Server"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
</location>
<!--network settings. Authenticationmodules: Specifies the module used to authenticate Internet requests. Connectionmanagement: Specifies the maximum number of connections to the Internet host. DefaultProxy: Configure the Hypertext Transfer Protocol (HTTP) proxy server. Mailsettings: Configure Simple Mail Transfer Protocol (SMTP) mail delivery options. Requestcaching: Controls the caching mechanism for network requests. Settings: Configures basic network options for System.Net. -->
<system.net>
<!--Configure SMTP e-mail settings-->
<mailSettings>
&LT;SMTP from= "Sy" >
<network host= "Gao" password= "username=" "/>
</smtp>
</mailSettings>
<!--Disable all cache-->
<requestcaching disableallcaching= "true" ></requestCaching>
<!--specify proxy addresses and bypass proxies for local access and contoso.com. -->
<defaultProxy>
<proxy usesystemdefault= "true" proxyaddress= "http://192.168.1.10:3128" bypassonlocal= "true"/>
<bypasslist>
<add address= ""/>
</bypasslist>
</defaultProxy>
</system.net>
<!--This section replaces AJAX-related HTTP handlers and modules added in the httphandlers and httpmodules sections. This section enables IIS 7.0 to work with these handlers and modules when it is running in Integrated mode. Running ASP.net AJAX under iis7.0 requires a system.webserver section. This section is not required for earlier versions of IIS. -->
<system.webServer>
<validation validateintegratedmodeconfiguration= "false"/>
<modules>
<add name= "Scriptmodule" precondition= integratedmode "type=" System.Web.Handlers.ScriptModule, System.Web.Extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35 "/>
</modules>
<remove name= "webservicehandlerfactory-integrated"/>
<add name= "ScriptHandlerFactory" verb= "*" path= "*.asmx" "precondition=" Integratedmode "type=" System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, version=3.5.0.0, Culture=neutral, Publickeytoken=31bf3856ad364e35 "/>
<add name= "scripthandlerfactoryappservices" verb= "*" path= "*_appservice.axd" precondition= "IntegratedMode" type= "System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, version=3.5.0.0, Culture=neutral, Publickeytoken=31bf3856ad364e35 "/>
<add name= "ScriptResource" precondition= "Integratedmode" verb= "Get,head" path= "ScriptResource.axd" System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, version=3.5.0.0, Culture=neutral, PublicKeyToken =31bf3856ad364e35 "/>
</system.webServer>
<!--configure asp.net services in asp.net AJAX-->
<system.web.extensions>
<!--Configure JSON serialization-->
<scripting>
<webServices>
<jsonserialization maxjsonlength= "5000"/>
</webServices>
</scripting>
</system.web.extensions>
<!--related configuration of WCF-->
<system.serviceModel>
<services>
<service name= "Wcfstudent.wcfstudenttext" behaviorconfiguration= "ServiceBehavior" >
<!--Service Endpoints-->
<endpoint address= "" binding= "Wshttpbinding" contract= "Wcfstudent.istuservicecontract" >
<!--deployment, the following identity elements should be removed or replaced to reflect the identity under which the deployment service runs. After the deletion, WCF automatically infers the corresponding identity. -->
<identity>
<dns value= "localhost"/>
</identity>
</endpoint>
<endpoint address= "Mex" binding= "mexHttpBinding" contract= "IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name= "ServiceBehavior" >
<!--to avoid leaking metadata information, set the following value to False before deployment and delete the metadata endpoint above-->
<servicemetadata httpgetenabled= "true"/>
<!--to receive fault exception details for debugging, set the following value to True. Set to false before deployment to avoid leaking exception information-->
<servicedebug includeexceptiondetailinfaults= "false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<!--URL redirection-->
<rewriter>
<rewrite url= "~/user/u (. +). aspx" to= "~/user/index.aspx?r=$1"/>
<rewrite url= "~/ask/q (. +). aspx" to= "~/home/ask/content.aspx?id=$1"/>
<rewrite url= "~/blog/b (. +). aspx" to= "~/home/blog/article.aspx?r=$1"/>
<rewrite url= "~/news/n (. +). aspx" to= "~/home/news/content.aspx?nid=$1"/>
<rewrite url= "~/default.aspx" to= "~/home/ram/net.aspx"/>
</rewriter>
</configuration>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.