ASPNETDB - 如何动态切换配置文件提供程序

发布于 2024-11-30 13:04:41 字数 3330 浏览 1 评论 0 原文

我有一个使用 ASPNETDB 来获取成员资格/角色/个人资料的网站。该网站有一些管理页面,我想添加几个新页面以便能够添加/编辑/删除该网站的用户。

我有两个不同的数据库连接字符串,具有不同的权限/安全级别。

我希望其中一个(“ASPNETDBConnection”)仅用于网站登录过程,以及所有访问者的其他一般用途。

我希望另一个(“ASPNETDBConnectionAdmin”)用于登录用户的添加/编辑/删除页面。

我不想创建虚拟目录/应用程序(不能 - 不要问!)。

据我所知,虽然我只能有一个配置文件,但我可以有多个提供程序...

以下内容取自我当前的 web.config 文件:

<system.web>
    <membership defaultProvider="AspNetSqlMembershipProvider">
        <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
            <add name="AspNetSqlMembershipProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
        </providers>
    </membership>
    <profile defaultProvider="AspNetSqlProfileProvider" enabled="true">
        <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="AspNetSqlProfileProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </profile>
    <roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
        <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="AspNetSqlRoleProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </roleManager>
</system.web>

我的问题是,如何切换提供程序?

如何在添加/编辑/用户页面的代码中将成员资格提供程序从默认的“AspNetSqlMembershipProvider”更改为替代提供程序“AspNetSqlMembershipProviderAdmin”(动态?)?

等人的角色&配置文件提供商。

请提供 VB(而不是 C#)方面的帮助。

非常感谢... 克里布普德

I have a web site that uses ASPNETDB for membership/roles/profiles. The web site has some administration pages and I want to add a couple of new pages to be able to add/edit/delete users for the web site.

I have two different connection strings for the database, with different permissions/levels of security.

I want one ("ASPNETDBConnection") to be used solely for the web site login process, and other general use purposes for all visitors.

I want the other ("ASPNETDBConnectionAdmin") to be used for the add/edit/delete pages for logged in users.

I do not want to create a virtual directory/application (cannot - don't ask!).

I gather that while I can have only one profile, I can have multiple providers...

The following is taken from my current web.config file:

<system.web>
    <membership defaultProvider="AspNetSqlMembershipProvider">
        <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
            <add name="AspNetSqlMembershipProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
        </providers>
    </membership>
    <profile defaultProvider="AspNetSqlProfileProvider" enabled="true">
        <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="AspNetSqlProfileProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </profile>
    <roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
        <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" connectionStringName="ASPNETDBConnection" applicationName="MyWebSite" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
            <add name="AspNetSqlRoleProviderAdmin" connectionStringName="ASPNETDBConnectionAdmin" applicationName="MyWebSite" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </roleManager>
</system.web>

My question is, how do I switch providers?

How do I change the membership provider from the default "AspNetSqlMembershipProvider" to the alternative one, "AspNetSqlMembershipProviderAdmin" (dynamically?) in the code for the add/edit/user pages?

Et al for role & profile providers.

Any help in VB, rather than C# please.

Many Thanks...
Crimblepud

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

变身佩奇 2024-12-07 13:04:41

我尝试在Crimblepud

上进行搜索,甚至尝试制作自定义分析器,但没有得到这个想法,在这之间我发现了一些有用的资源,请在

配置文件上的代码项目

配置文件机制

Crimblepud

I tried to search, on it and even i tried making custom profiler,but not getting the idea, in between i found some useful resources,check it on

Code Project on Profile

Profile Mechanism

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文