"记住我"在ASP.NET MVC认证不工作 [英] "Remember me" with ASP.NET MVC Authentication is not working

查看:254
本文介绍了"记住我"在ASP.NET MVC认证不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标准的ASP.NET MVC(RC刷新)Web项目,与标准的ASP.NET成员资格供应商和客户控制器包含在项目模板。

I have a standard ASP.NET MVC (RC Refresh) web project, with the standard ASP.NET Membership provider and the Account controller that is included in the project template.

当我选中记住我在我的登录表单,我仍然没有被记住的网站。 (火狐记住我的用户名和密码,但我预计最快还是被自动登录)。

When I check "Remember me" in my Login form, I am still not being remembered by the site. (Firefox remembers my username and password, but what I expected to happen was to be automatically logged on).

我是否设置和手动检查饼干吗?如果是的话,应如何最好做?

Do I have to set and check the cookie manually? If so, how should it best be done?

推荐答案

您需要通过真/假的SetAuthCookie方法。

You need to pass true/false to the SetAuthCookie method.

public ActionResult Login (string email, string password, bool rememberMe, string returnUrl)  
{

    // snip

    FormsAuth.SetAuthCookie(username, rememberMe); // <- true/false

    // snip
}

和确保 BOOL了rememberMe 反映该复选框在您的登录页面的状态。

and make sure that bool rememberMe reflects the status of the checkbox on your login page.

这篇关于&QUOT;记住我&QUOT;在ASP.NET MVC认证不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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