ASP.NET web.config 程序配置文件
1,对每个文件夹有不同的访问权限:
可以在每个文件夹下添加相应的web.config ,来分别进行设置。
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<authentication mode="Forms"> <!-- 认证方式 -->
</authentication>
<authorization> <!--授权 委任 -->
<deny users="?"/>
</authorization>
</system.web>
</configuration>
2,使用Login控件连接数据库时要配置连接字符串和MembershipProvider
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<authentication mode="Forms"/>
<membership defaultProvider="SqlProvider"
userIsOnlineTimeWindow = "20>
<providers>
<add
name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
requiresQuestionAndAnswer="true"
minRequiredNonalphanumericCharacters="1"
/>
</providers>
</membership>
<!--用户角色提供程序-->
<roleManager
cacheRolesInCookie="true"
cookieName="name"
cookiePath="/"
cookieProtection="All"
cookieRequireSSL="true"
cookieSlidingExpiration="true"
cookieTimeout="300"
createPersistentCookie="true"
defaultProvider="myroleshipprovider"
domain="cookie domain"
enabled="true"
maxCachedResults="25">
<providers>
<add name="myroleshipprovider" connectionStringName="simpleshopConnectionString" type="System.Web.Security.SqlRoleProvider,System.Web,Version=2.0.0.0,culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"></add>
</providers>
</roleManager>
3,自定义错误页:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<configuration>
<System.web>
<customErrors mode="RemoteOnly" defaultRedirect="/generic.aspx">
<error statusCode="404" redirect="/ErrorPages/Error404.aspx" />
<error statusCode="500" redirect="/ErrorPages/Error500.aspx" />
</customErrors>
</System.web>
</configuration>
4,用户配置文件:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<anonymousIdentification enable="true" />
<profile enable="true">
<properties>
<add name="BackColor" type="System.Drawing.Color" allowAnonymous="true" />
<add name="Links" type="System.Collections.Specialized.StringCollection" serializAs="Xml" />
</properties>
</profile>
4,
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
posted on 2010-07-14 08:32 Henry_Wang 阅读(207) 评论(0) 编辑 收藏 举报