简体   繁体   中英

Using ASP.NET Membership tables in MVC

I have a "user management portal" created in .NET 4 Web forms. The portal allows administrators to add and edit users to specific applications (new users get a randomly generated password that's encrypted with whatever web forms uses).

I want to build an MVC 4 website that authenticates to those usernames and passwords. I know that SimpleMembership is part of ASP Membership but I'm not sure how to go about using the default created website to validate against the webforms username and password. It's not so simple to just set the machine key in the web.config and change the DB to the membership DB.

So for instance:

  • User A created in the web forms app with password 1234567
  • User A clicks the login button on default MVC app and uses password 1234567 (MVC app defaultConnection string is set to Web form apps database)

Does anyone have any tutorials on this or able to help?

I believe that in SimpleMembership you can define the "User Profile" table, however it creates its own tables for use with passwords.

For instance, you can take any Model class and annotate it with [Table("UserProfile")] To get SimpleMemebrship to use it as the profile table.

Also this answer Entity Framework Code-First Issues (SimpleMembership UserProfile table) helped me a lot in modifying SimpleMemberhip to use my tables.

I think this may be close to what you are lookign for: http://blog.spontaneouspublicity.com/including-asp-net-simple-membership-tables-as-part-of-your-entity-framework-model I think this shows how to set other tables that the default for use with SimpleMembership

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM