Membership provider with different ApplicationName in area

▼魔方 西西 提交于 2019-12-07 23:51:33

问题


I have a web.config in my MVC3 application, I have an Admin area in my MVC3 application too.

On the front end I hook asp.net users into a Customers table and my application relies on this table to operate. In the Admin area I have an Administrator Role and User but this login also works for the front end. I can create a customer for my Admin so my application doesn't fail but ideally I would like to separate the logins from the front and Admin area.

I want to put a second web.config inside my Admin area that has a different application name so that the Admin account can never be logged into the front end. e.g.

    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SecurityConn" applicationName="/" />
      </providers>
    </profile>

But I don't know where to put this or if it is even possible

applicationName="/AdminArea"

回答1:


You can add more than one provider in the section with different applicationname.

What you will need to consider is how you would switch between those providers. You can use the providers collection e.g.

Membership.Providers["MyOtherProvider"].ValidateUser(username, pwd);

So you will need a mechanism to know who is logging in (Admin or customer).



来源:https://stackoverflow.com/questions/13066750/membership-provider-with-different-applicationname-in-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!