asp.net - 如何从 asp 网站管理工具启用角色管理器

标签 asp.net sql roleprovider

嗨,我正在尝试在 asp 网站管理工具中启用角色,但是当转到安全选项卡时,它给了我这个错误

There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

我正在使用自己的connectionStrings将其链接到sql server management studio 2012而不是Visual Studio中的sql CE是代码

 <connectionStrings>

<add name="MusicStoreEntities"
     connectionString="Data Source=localhost;
     Initial Catalog=Project4DB;
     Integrated Security=true;
     MultipleActiveResultSets=true"

     providerName="System.Data.SqlClient" /> 
</connectionStrings>

那么在这种情况下如何启用角色呢?

最佳答案

您好,经过多次搜索和数小时后,我设法使 ASP 网站管理工具安全选项卡正常工作。 连接到常规server management studio 2012不是 Visual Studio 自带的

首先在 web.config 文件中进行以下更改:

注意:我们必须首先在 server management studio 2012 中创建数据库。

1) 添加连接字符串

 <connectionStrings>

    <add name="MusicStoreEntities" --> change the name to your own connection name 
     connectionString="Data Source=localhost;
     Initial Catalog=Project4DB; --> change it to your one database name
     Integrated Security=true;
     MultipleActiveResultSets=true"
     providerName="System.Data.SqlClient" />

 </connectionStrings>

2) 在 <system.web>在 web.config 中添加部分

<roleManager enabled="false" 
  cacheRolesInCookie="false" 
  cookieName=".ASPXROLES" 
  cookieTimeout="30" 
  cookiePath="/" 
  cookieRequireSSL="false" 
  cookieSlidingExpiration="true" 
  cookieProtection="All" 
  defaultProvider="AspNetSqlRoleProvider" 
  createPersistentCookie="false" 
  maxCachedResults="25">

  <providers>
  <clear />
  <add connectionStringName="MusicStoreEntities" --> change the name to your own connection name
       applicationName="/" 
       name="AspNetSqlRoleProvider" 
       type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

 <add name="AspNetWindowsTokenRoleProvider" 
      applicationName="/" 
      type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

  </providers>
</roleManager>

<membership>
  <providers>
    <remove name="AspNetSqlMembershipProvider"/>
    <add name="AspNetSqlMembershipProvider" 
        type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="MusicStoreEntities" --> change the name to your own connection name
        enablePasswordRetrieval="false" 
        enablePasswordReset="true" 
        requiresQuestionAndAnswer="true" 
        applicationName="/" 
        requiresUniqueEmail="false" 
        passwordFormat="Hashed" 
        maxInvalidPasswordAttempts="5" 
        minRequiredPasswordLength="7" 
        minRequiredNonalphanumericCharacters="1" 
        passwordAttemptWindow="10" 
        passwordStrengthRegularExpression=""/>
</providers>
</membership>

<customErrors mode="Off" />

3) 打开aspnet_regsql从: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

并按照设置向导进行操作

hit next

点击下一个

点击下一步

选择要连接的数据库,然后下一步

ASP 网站管理工具中的安全选项卡将启用这些角色。

关于asp.net - 如何从 asp 网站管理工具启用角色管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22631096/

相关文章:

FireFox 中的 Java 错误 - myApplet.myFunction 不是函数

mysql - 加速连接两个巨大表的查询

asp.net-mvc - 如果这样配置的话,asp.net RoleManager 真的会在 cookie 中缓存用户的角色吗?

mysql - SQL:选择行不属于同一表内条件的事务

sql - 如何制作 ORDER SIBLINGS BY?

c# - ASP.NET 成员资格和角色提供者配置问题

cookies - ASP.NET 通用提供程序 - Roleprovider 不会在 cookie 中缓存角色

c# - 如何将 Excel 中的命名范围与 OleDB 一起使用?

asp.net - 在 ASP.NET 中以编程方式创建用户控件实例

asp.net - 使用SqlDataReader时如何获取存储过程的返回值?