WebConfig 常用配置信息,转载备用

来源:互联网 发布:阿里云网站绑定域名 编辑:程序博客网 时间:2024/05/04 00:43
 
  1. <?xml version="1.0"?>  
  2. <configuration>  
  3.   <configSections>  
  4.     <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>  
  5.   </configSections>  
  6.      
  7.   <!--URLRewriter重写规则-->  
  8.   <RewriterConfig>  
  9.     <Rules>  
  10.       <RewriterRule>  
  11.         <LookFor>~/(\d+).aspx</LookFor>  
  12.         <SendTo>~/Default.aspx?page=$1</SendTo>  
  13.       </RewriterRule>  
  14.     </Rules>  
  15.   </RewriterConfig>  
  16.      
  17.      
  18.      
  19.   <!--System.Configuration.ConfigurationSettings.AppSettings["SocutDataLink"];-->  
  20.   <!--传说中以前.net1.1用这个保存数据库链接,如今可以用这个来保存一些配置-->  
  21.   <appSettings>  
  22.     <add key="SocutDataLink" value="Data/db1.mdb"/>  
  23.     <add key="Domain" value="http://www.yongfa365.com/"/>  
  24.     <add key="Author" value="柳永法,yongfa365"/>  
  25.   </appSettings>  
  26.      
  27.   <!--System.ConfigurationConfigurationManager.ConnectionStrings["SqlConnection"].ProviderName;-->  
  28.   <!--System.ConfigurationConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;-->  
  29.   <!--.net2.0用这个保存数据库链接-->  
  30.   <connectionStrings>  
  31.     <add name="SqlConnection" connectionString="Data Source=.\SQL2005;Initial Catalog=MSSQLDB;Integrated Security=True" providerName="System.Data.SqlClient"/>  
  32.     <add name="SqlConnection2" connectionString="Data Source=.\SQL2005;Initial Catalog=MSSQLDB;Persist Security Info=True;User ID=usr;Password=pwd" providerName="System.Data.SqlClient"/>  
  33.     <add name="AccessConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Data\mydb.mdb;" providerName="System.Data.OleDb"/>  
  34.     <!--<remove name="LocalSqlServer"/>  
  35.     <add name="LocalSqlServer" connectionString="Data Source=YONGFA365\SQL2005;Initial Catalog=管理员;Integrated Security=True" providerName="System.Data.SqlClient"/>-->  
  36.   </connectionStrings>  
  37.      
  38.      
  39.   
  40.   
  41.   <system.web>  
  42.     <!--调试否,设计设为时true,发布后设为false-->  
  43.     <compilation debug="false"/>  
  44.     <!--错误显示-->  
  45.     <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">  
  46.       <error statusCode="403" redirect="NoAccess.htm"/>  
  47.       <error statusCode="404" redirect="FileNotFound.htm"/>  
  48.       <error statusCode="500" redirect="InternalError.htm"/>  
  49.     </customErrors>  
  50.   
  51.     <httpModules>  
  52.       <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>  
  53.     </httpModules>  
  54.     <!--   
  55.     <httpHandlers>  
  56.      <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />  
  57.      <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />  
  58.     </httpHandlers>  
  59.      -->  
  60.        
  61.   </system.web>  
  62.      
  63.      
  64.      
  65.   <!--■■■■■■■■■■■■■■■■■■■用户、角色配置 start■■■■■■■■■■■■■■■■■■■-->  
  66.   <system.web>  
  67.     <!--验证模式 mode="[Windows|Forms|Passport|None],一般用Forms"-->  
  68.     <authentication mode="Forms">  
  69.       <forms loginUrl="login.aspx" name=".CommunityServer"/>  
  70.     </authentication>  
  71.     <!--为了兼容其它数据库的Provider写的,用的还都是默认的Provider-->  
  72.     <membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="20">  
  73.       <providers>  
  74.         <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SqlConnection" applicationName="LivePortal" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"/>  
  75.       </providers>  
  76.     </membership>  
  77.     <profile defaultProvider="SqlProfileProvider">  
  78.       <providers>  
  79.         <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SqlConnection"/>  
  80.       </providers>  
  81.     </profile>  
  82.     <roleManager defaultProvider="SqlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">  
  83.       <providers>  
  84.         <clear/>  
  85.         <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SqlConnection" applicationName="LivePortal"/>  
  86.       </providers>  
  87.     </roleManager>  
  88.   </system.web>  
  89.   <!--用户,角色 权限[roles|users]="一个逗号分隔的角色或用户列表"-->  
  90.   <location path="admin">  
  91.     <system.web>  
  92.       <authorization>  
  93.         <allow roles="管理员,二级管理员,三级管理员"/>  
  94.         <deny users="*"/>  
  95.       </authorization>  
  96.     </system.web>  
  97.   </location>  
  98.   <location path="ChangePassword.aspx">  
  99.     <system.web>  
  100.       <authorization>  
  101.         <allow users="登录用户,管理员"/>  
  102.         <deny users="?"/>  
  103.       </authorization>  
  104.     </system.web>  
  105.   </location>  
  106.   <!--配置发送邮件的SMTP信息,为找回密码用-->  
  107.   <system.net>  
  108.     <mailSettings>  
  109.       <smtp from="yongfa365@qq.com">  
  110.         <network host="smtp.qq.com" password="64049027" port="25" userName="yongfa365"/>  
  111.       </smtp>  
  112.     </mailSettings>  
  113.   </system.net>  
  114.   <!--■■■■■■■■■■■■■■■■■■■用户、角色配置 end■■■■■■■■■■■■■■■■■■■-->  
  115. </configuration>  

 

<!--■■■■■■■■■■■■■■参考配置,使用时自己调整,无法直接使用■■■■■■■■■■■■--><?xml version="1.0"?><configuration>  <!--■■■■■■■■■■■■■■■■■■■伪静态配置 start■■■■■■■■■■■■■■■■■■■-->  <configSections>    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>  </configSections>  <!--URLRewriter重写规则-->  <RewriterConfig>    <Rules>      <RewriterRule>        <LookFor>~/(\d+).aspx</LookFor>        <SendTo>~/Default.aspx?page=$1</SendTo>      </RewriterRule>    </Rules>  </RewriterConfig>  <system.web>    <httpModules>      <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>    </httpModules>    <!--    <httpHandlers>     <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />     <add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />    </httpHandlers>     -->  </system.web>  <!--■■■■■■■■■■■■■■■■■■■伪静态配置 end■■■■■■■■■■■■■■■■■■■-->  <!--System.Configuration.ConfigurationSettings.AppSettings["SocutDataLink"];-->  <!--传说中以前.net1.1用这个保存数据库链接,如今可以用这个来保存一些配置-->  <appSettings>    <add key="SocutDataLink" value="Data/db1.mdb"/>    <add key="Domain" value="http://www.yongfa365.com/"/>    <add key="Author" value="柳永法,yongfa365"/>  </appSettings>  <!--System.ConfigurationConfigurationManager.ConnectionStrings["SqlConnection"].ProviderName;-->  <!--System.ConfigurationConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;-->  <!--.net2.0用这个保存数据库链接-->  <connectionStrings>    <add name="SqlConnection" connectionString="Data Source=.\SQL2005;Initial Catalog=liveportal;Integrated Security=True" providerName="System.Data.SqlClient"/>    <add name="SqlConnection2" connectionString="Data Source=.\SQL2005;Initial Catalog=MSSQLDB;Persist Security Info=True;User ID=usr;Password=pwd" providerName="System.Data.SqlClient"/>    <add name="AccessConnection" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\Data\mydb.mdb;" providerName="System.Data.OleDb"/>    <!--<remove name="LocalSqlServer"/>    <add name="LocalSqlServer" connectionString="Data Source=YONGFA365\SQL2005;Initial Catalog=管理员;Integrated Security=True" providerName="System.Data.SqlClient"/>-->  </connectionStrings>  <system.web>    <!--调试否,设计设为时true,发布后设为false-->    <compilation debug="false"/>    <!--错误显示-->    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">      <error statusCode="403" redirect="NoAccess.htm"/>      <error statusCode="404" redirect="FileNotFound.htm"/>      <error statusCode="500" redirect="InternalError.htm"/>    </customErrors>  </system.web>  <!--■■■■■■■■■■■■■■■■■■■用户、角色配置 start■■■■■■■■■■■■■■■■■■■-->  <system.web>    <!--验证模式 mode="[Windows|Forms|Passport|None],一般用Forms"-->    <authentication mode="Forms">      <forms loginUrl="login.aspx" name=".CommunityServer"/>    </authentication>    <!--为了兼容其它数据库的Provider写的,用的还都是默认的Provider-->    <membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="20">      <providers>        <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SqlConnection" applicationName="LivePortal" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"/>      </providers>    </membership>    <profile defaultProvider="SqlProfileProvider">      <providers>        <add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SqlConnection"/>      </providers>    </profile>    <roleManager defaultProvider="SqlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">      <providers>        <clear/>        <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="SqlConnection" applicationName="LivePortal"/>      </providers>    </roleManager>  </system.web>  <!--用户,角色 权限[roles|users]="一个逗号分隔的角色或用户列表"-->  <location path="admin">    <system.web>      <authorization>        <allow roles="管理员,二级管理员,三级管理员"/>        <deny users="*"/>      </authorization>    </system.web>  </location>  <location path="ChangePassword.aspx">    <system.web>      <authorization>        <allow users="登录用户,管理员"/>        <deny users="?"/>      </authorization>    </system.web>  </location>  <!--配置发送邮件的SMTP信息,为找回密码用-->  <system.net>    <mailSettings>      <smtp from="yongfa365@qq.com">        <network host="smtp.qq.com" password="64049027" port="25" userName="yongfa365"/>      </smtp>    </mailSettings>  </system.net>  <!--■■■■■■■■■■■■■■■■■■■用户、角色配置 end■■■■■■■■■■■■■■■■■■■--></configuration>
原创粉丝点击