在web.config中,默认的角色和成员(还有webparts等),默认的数据库都是SQL Express 2005,而且默认的连接名称是 LocalSqlServer 。在下面的完整配置中,将启用 SQL Server 2000 作为其数据库,并且把连接名称改为 LocalDataServer。
在此之前,请运行.Net安装目录(一般为 C:/windows/microsoft.net/framework/v2.0.50727/)中的 aspnet_regsql.exe ,根据向导在 SQL Server 2000 中生成需要的数据库、数据表及存储过程和视图。然后,按下面的代码建立 web.config 即可。
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.c...
<connectionStrings>
<add name="LocalDataServer" connectionString="server=.;database=entbase;uid=sa;pwd=sa;" />
</connectionStrings>
<system.web>
<compilation debug="false"></compilation>
<membership>
<providers>
<remove name="AspNetSqlMembershipProvider" />
<add connectionStringName="LocalDataServer" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="5"
passwordStrengthRegularExpression="" name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<authentication mode="Forms">
<forms name=".AspNetCookieName" loginUrl="login.aspx" protection="All" slidingExpiration="true" timeout="30" defaultUrl="index.aspx" />
</authentication>
<roleManager enabled="true">
<providers>
<remove name="AspNetSqlRoleProvider" />
<add connectionStringName="LocalDataServer" applicationName="/"
name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<webServices>
<protocols>
<remove name="HttpGet"/>
<remove name="HttpPost"/>
<remove name="Unknown"/>
</protocols>
</webServices>
<webParts>
<personalization defaultProvider="AspNetSqlProvider">
<providers>
<remove name="AspNetSqlProvider"/>
<add name="AspNetSqlProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalDataServer" />
</providers>
</personalization>
</webParts>
</system.web>
<location path="thispageneedlogin.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
ASP.NET2.0中的角色和成员功能以及WebParts的配置
最新推荐文章于 2024-08-26 09:58:57 发布