.Net 表单身份验证

发布于 2024-10-06 16:10:32 字数 73 浏览 0 评论 0原文

我正在 mvc2 中开发一个网站,并且使用 .net 身份验证。我该如何更改我的登录授权以使用电子邮件和密码。

谢谢

I'm developing a website in mvc2, and i'm using the .net Authentication. How can i do to change my login authorization to use email and password.

thanks

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

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

发布评论

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

评论(1

撕心裂肺的伤痛 2024-10-13 16:10:32

在发出身份验证 cookie 的控制器操作内,只需检查邮件是否与密码匹配,并使用电子邮件作为身份验证 cookie 的用户名:

[HttpPost]
public ActionResult Login(string email, string password)
{
    // TODO: query your membership provider and verify if the given email
    // matches the password and if they match emit the authentication cookie
    // using the email as username

}

Inside your controller action which emits the authentication cookie just check if the mail matches the password and use the email as username for the authentication cookie:

[HttpPost]
public ActionResult Login(string email, string password)
{
    // TODO: query your membership provider and verify if the given email
    // matches the password and if they match emit the authentication cookie
    // using the email as username

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