您的位置:首页 > 其它

WebConfig里的配置成员资格角色管理

2007-08-14 11:32 232 查看
把连接改一下,先清掉Machine.config里的连接,再加一条,最好名字一样,不然在Asp.net配置那里会有点麻烦。


<connectionStrings>


<clear/>


<add name="LocalSqlServer" connectionString="Data Source=.;Initial Catalog=SocanCRM;Persist Security Info=True;User ID=sa;Password="


providerName="System.Data.SqlClient" />


</connectionStrings>

然后配置以下三个节点


<membership>


<providers>


<clear/>


<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="SocanCRM" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>


</providers>


</membership>


<profile>


<properties>


<add name="UserProfile" type="String" allowAnonymous="false" />


</properties>


<providers>


<clear/>


<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="SocanCRM" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>


</providers>


</profile>


<roleManager enabled="true">


<providers>


<clear/>


<add connectionStringName="LocalSqlServer" applicationName="SocanCRM" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>


</providers>


</roleManager>

profile节里必须有东西才行,不然Profile.UserName一直为空,但可以用User.Identity.Name
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: