嗨,我正在尝试在 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
并按照设置向导进行操作
点击下一个
点击下一步
选择要连接的数据库,然后下一步
ASP 网站管理工具中的安全选项卡将启用这些角色。
关于asp.net - 如何从 asp 网站管理工具启用角色管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22631096/