ASP.NET的WebConfig

WebConfig

花了点时间整理了一下ASP.NET Web.config配置文件的基本使用方法。很适合新手参看,由于Web.config在使用很灵活,可以自定义一些节点。所以这里只介绍一些比较常用的节点。

xml version="1.0"?>

 

<configuration>

  

 <configSections>

    <sectionGroup name="system.web.extensionstype="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

      <sectionGroup name="scriptingtype="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

        <section name="scriptResourceHandlertype="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="falseallowDefinition="MachineToApplication"/>

      sectionGroup>

    sectionGroup>

    <section name="rewritertype="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />

 configSections>

 

 

     <appSettings>

 <add key="1value="1" />

 <add key="gaovalue="weipeng" />

 appSettings>

 

 

 <connectionStrings>

    <add name="ConnStringconnectionString="Data Source=GAO;Initial Catalog=HBWXDate;User ID=sa;password=sa">add>

    <add name="111connectionString="11111" />

 connectionStrings>

 

 

 <location path="Default.aspxallowOverride="false">

    

<system.web>

   

    <identity impersonate="false" />

   

   

    <pages masterPageFile="Indextheme="Defaultbuffer="trueenableViewStateMac="truevalidateRequest="false"enableViewState="false">

     

      <controls>controls>

     

      <namespaces>namespaces>

    pages>

   

   

    <customErrors defaultRedirect="Err.htmlmode="RemoteOnly">

     

      <error statusCode="403redirect="NoAccess.htm" />

      <error statusCode="404redirect="FileNotFound.htm" />

    customErrors>

   

   

    <trace enabled="truelocalOnly="falsepageOutput="truerequestLimit="15traceMode="SortByCategory"/>

   

   

    <compilation debug="truedefaultLanguage="c#batch="false">

      <assemblies>

       

        <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>

     

      <buildProviders>

       

        <add extension=".aspxtype="System.Web.Compilation.PageBuildProvider"/>

        <add extension=".ascxtype="System.Web.Compilation.UserControlBuildProvider"/>

        <add extension=".mastertype="System.Web.Compilation.MasterPageBuildProvider"/>

        <add extension=".asmxtype="System.Web.Compilation.WebServiceBuildProvider"/>

        <add extension=".ashxtype="System.Web.Compilation.WebHandlerBuildProvider"/>

        <add extension=".soaptype="System.Web.Compilation.WebServiceBuildProvider"/>

        <add extension=".resxtype="System.Web.Compilation.ResXBuildProvider"/>

        <add extension=".resourcestype="System.Web.Compilation.ResourcesBuildProvider"/>

        <add extension=".wsdltype="System.Web.Compilation.WsdlBuildProvider"/>

        <add extension=".xsdtype="System.Web.Compilation.XsdBuildProvider"/>

        <add extension=".rdlctype="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

      buildProviders>

    compilation>

   

      

    <authentication mode="Forms">

     

      <forms name=".ASPXUSERDEMOloginUrl="Login.aspxprotection="Alltimeout="30"/>

    authentication>

   

    <authorization>

      <allow users="*"/>

      <deny users="weipeng"/>

      <allow users="aaroles="aa" />

    authorization>

   

    <globalization requestEncoding="gb2312responseEncoding="gb2312fileEncoding="gb2312" />

   

    <sessionState mode="InProcstateConnectionString="tcpip=127.0.0.1:42424sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yescookieless="falsetimeout="20">sessionState>

   

    <sessionPageState historySize="9"/>   

   

    <httpRuntime appRequestQueueLimit="100executionTimeout="80maxRequestLength="40960"useFullyQualifiedRedirectUrl="false"/>

   

    <httpModules>

      <add name="OutputCachetype="System.Web.Caching.OutputCacheModule" />

      <add name="Sessiontype="System.Web.SessionState.SessionStateModule" />

      <add name="WindowsAuthenticationtype="System.Web.Security.WindowsAuthenticationModule" />

      <add name="FormsAuthenticationtype="System.Web.Security.FormsAuthenticationModule" />

      <add name="PassportAuthenticationtype="System.Web.Security.PassportAuthenticationModule" />

      <add name="RoleManagertype="System.Web.Security.RoleManagerModule" />

      <add name="UrlAuthorizationtype="System.Web.Security.UrlAuthorizationModule" />

      <add name="FileAuthorizationtype="System.Web.Security.FileAuthorizationModule" />

      <add name="AnonymousIdentificationtype="System.Web.Security.AnonymousIdentificationModule" />

     

      <add name="UrlRewritertype="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />

      <add name="Profiletype="System.Web.Profile.ProfileModule" />

    httpModules> 

   

    <httpHandlers>

      <remove verb="*path="*.asmx"/>

      <add verb="*path="*.asmxvalidate="falsetype="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add verb="*path="*_AppService.axdvalidate="falsetype="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add verb="GET,HEADpath="ScriptResource.axdtype="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35validate="false"/>

      <add verb="POST,GETpath="ajaxpro/*.ashxtype="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>

    httpHandlers>

   

    <httpCookies httpOnlyCookies="falserequireSSL="false"/> 

   

    <webServices>

      <protocols>

        <add/>

      protocols>

    webServices>

   

    <caching>

      <cache disableMemoryCollection = "falsedisableExpiration = "falseprivateBytesLimit = "0"percentagePhysicalMemoryUsedLimit = "90privateBytesPollTime = "00:02:00"/>

     

      <outputCacheSettings>

        <outputCacheProfiles>

          <add name="ServerOnlyduration="60varyByCustom="browserlocation="Server" />

        outputCacheProfiles>

      outputCacheSettings>

    caching>

     system.web>

 

 location>

 

 <system.net>

 

 <mailSettings>

   <smtp from="weipeng">

    <network host="Gaopassword="" userName="" />

   smtp>

 mailSettings>

  

   <requestCaching disableAllCaching="true">requestCaching>

  

   <defaultProxy>

     <proxy usesystemdefault="Trueproxyaddress="http://192.168.1.10:3128bypassonlocal="True"/>

     <bypasslist>

       <add address="[a-z]+".contoso".com" />

     bypasslist>

   defaultProxy>

 system.net>

 

 <system.webServer>

    <validation validateIntegratedModeConfiguration="false"/>

    <modules>

      <add name="ScriptModulepreCondition="integratedModetype="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

    modules>

    <handlers>

      <remove name="WebServiceHandlerFactory-Integrated"/>

      <add name="ScriptHandlerFactoryverb="*path="*.asmxpreCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add name="ScriptHandlerFactoryAppServicesverb="*path="*_AppService.axdpreCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

      <add name="ScriptResourcepreCondition="integratedModeverb="GET,HEADpath="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

    handlers>

 system.webServer>

 

 

 <system.web.extensions>

   

    <scripting>

      <webServices>

        <jsonSerialization maxJsonLength="5000"/>

      webServices>

    scripting>

 system.web.extensions>

 

 <system.serviceModel>

    <services>

      <service name="WCFStudent.WCFStudentTextbehaviorConfiguration="ServiceBehavior">

       

        <endpoint address="" binding="wsHttpBindingcontract="WCFStudent.IStuServiceContract">

         

          <identity>

            <dns value="localhost"/>

          identity>

        endpoint>

        <endpoint address="mexbinding="mexHttpBindingcontract="IMetadataExchange"/>

      service>

    services>

    <behaviors>

      <serviceBehaviors>

        <behavior name="ServiceBehavior">

         

          <serviceMetadata httpGetEnabled="true"/>

         

          <serviceDebug includeExceptionDetailInFaults="false"/>

        behavior>

      serviceBehaviors>

    behaviors>

 system.serviceModel>

 

 

 <rewriter>

    <rewrite url="~/user/u(.+).aspxto="~/user/index.aspx?r=$1" />

    <rewrite url="~/ask/q(.+).aspxto="~/home/ask/content.aspx?id=$1" />

    <rewrite url="~/blog/b(.+).aspxto="~/home/blog/article.aspx?r=$1" />

    <rewrite url="~/news/n(.+).aspxto="~/home/news/content.aspx?nid=$1" />

    <rewrite url="~/default.aspxto="~/home/ram/net.aspx" />

 rewriter>

configuration>

你可能感兴趣的:(ASP)