ASP.Net MVC窗体身份验证和成员资格提供 [英] ASP.Net MVC Forms Authentication and membership provider

查看:190
本文介绍了ASP.Net MVC窗体身份验证和成员资格提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.Net MVC,是窗体身份验证和成员资格提供紧密耦合?
成员资格提供模型比,我已经有我需要与整合现有的用户认证服务有很大不同。我想写我自己的类来管理用户,但仍使用内置的窗体身份验证,并形成cookie来允许登录的用户访问网站的身份验证的部分。

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.

我可以只删除web.config中提及的MembershipProvider和我用它来验证用户控制器打电话给我自己的自定义类?将窗体身份验证仍然有效?

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?

推荐答案

您可以创建一个自定义的成员提供如@negadro提及或只需调用的 SetAuthCookie您的自定义验证后

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);

这篇关于ASP.Net MVC窗体身份验证和成员资格提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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