ASP.Net MVC Forms Authentication and membership provider

江枫思渺然 提交于 2019-12-11 10:33:50

问题


In ASP.Net MVC, are the Forms Authentication and Membership Provider tightly coupled? The Membership provider model is very different than the existing user validation services that I already have that I need to integrate with. I would like to write my own class to manage users, but still use the built in forms authentication and forms cookie to allow a logged-in user to access authenticated sections of the website.

Can I just delete the reference to the MemberShipProvider from web.config and call my own custom class from the controller I use to validate users? Will Forms Authentication still work?


回答1:


You can either create a custom membership provider as @negadro mentioned or just call the SetAuthCookie after your custom validation.

//your custom validation logic here
FormsAuthentication.SetAuthCookie(userName, rememberMe);



回答2:


You can create custom membership provider. This answer will help you , i think. How do I create a custom membership provider for ASP.NET MVC 2



来源:https://stackoverflow.com/questions/8874944/asp-net-mvc-forms-authentication-and-membership-provider

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