為了方便配置web.config文件,我寫了一個常用的web.config文件的示例,可以以此為模版根據需要修改。
創建web.config文件的三種快捷方法:
1、用VS2005中的ASP.Net網站配置工具配置
2、參考C:\Windows\Microsoft.NET\Framework\v2.0.50727(.Net framework版本)\CONFIG\目錄下的Machine.config 文件進行編寫
3、以下邊這個文件作模版修改
點擊此處展開代碼
<?XML version="1.0" encoding="utf-8"?>
<!--
注意: 除了手動編輯此文件以外,您還可以使用
Web 管理工具來配置應用程序的設置。可以使用 Visual Studio 中的
“網站”->“ASP.Net 配置”選項。
設置和注釋的完整列表在
Machine.config.comments 中,該文件通常位於
\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"
&
nbsp; passWordAttemptWindow="10"
passWordStrengthRegularExpression=""
description="存儲membership數據"
/>
</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="存儲Profile數據"
/>
</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="存儲Role數據"
/>
</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>
http://www.cnblogs.com/andymore/archive/2006/10/03/520759.Html