ASP.Net成员:保存在不同的数据库角色 [英] ASP.Net Membership: Roles saved on Different Database

查看:91
本文介绍了ASP.Net成员:保存在不同的数据库角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习如何操纵Membership类。

I'm learning about how to manipulate the Membership class.

我一直在使用aspnet_regsql.exe的,到目前为止,我可以列出和添加用户没有问题加入会员数据库到我的网站的SQL数据库。不过,我决定增加使用ASP.Net配置工具一些角色。新加的角色,但在我的SQL数据库的表aspnet_Roles并未现身。

I have added the Membership database to my website's SQL Database using aspnet_regsql.exe and so far I can list and add users without a problem. However, I decided to add some roles using the ASP.Net Configuration Tool. The roles were added, but did not show up in the aspnet_Roles table of my SQL database.

我因为在我的VS2010 App_Data文件夹中发现ASPNETDB.MDF有问题的网站和角色都出现在那里。用户没有在该数据库中,但在SQL数据库在我的web.config文件中配置:

I have since noticed ASPNETDB.MDF in my VS2010 App_Data folder for the website in question and the Roles are appearing in there. The users are not in that database but are in the SQL DB configured in my web.config file:

<configuration> 
    <connectionStrings>
        <add name="myConnString" connectionString="Data Source=SQLDB;Initial Catalog=myDatabase;User ID=myUser;Password=myPassword" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.web>
        <authentication mode="Forms" />
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </assemblies>
        </compilation>
        <machineKey validationKey="LOTSOFNUMBERS"
        decryptionKey="MORENUMBERS" validation="SHA1" decryption="AES"/>
        <membership  defaultProvider="SqlProvider">
            <providers>
                <clear/>
                <add name="SqlProvider"
                connectionStringName="myConnString"
                type="System.Web.Security.SqlMembershipProvider"
                applicationName="myApp"
                requiresUniqueEmail="true"
                minRequiredPasswordLength="8"
                minRequiredNonalphanumericCharacters="0"
                requiresQuestionAndAnswer="false"
                passwordFormat="Encrypted"
                enablePasswordRetrieval="true"
                />
            </providers>
        </membership>
        <roleManager enabled="true" />
        <pages theme="myTheme">
        </pages>
        <authorization>
            <deny users="?"/>
        </authorization>
    </system.web>
</configuration>

如果用户可以保存,修改和使用我的数据库中的ASP.Net配置工具删除,那么我本来期望的角色做?我错过了哪一步?

If the users can be saved, modified and deleted using the ASP.Net Configuration Tool on my database, then I would have expected the Roles to do the same? What step am I missing?

推荐答案

您缺少roleManager。下面是一个例子:

You are missing roleManager. Here is an example:

<roleManager enabled="true">
    <providers>
        <clear />
        <add connectionStringName="myConnString" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
        <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
    </providers>
</roleManager>

这篇关于ASP.Net成员:保存在不同的数据库角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆