Asp.net mvc 如何获取有关cookie过期日期的表单身份验证票证
我有一个问题,我的网站登录会话的用户是到期之前的方式应该 这是我的登录方法“Asp.net mvc 如何获取有关cookie过期日期的表单身份验证票证,asp.net-mvc,asp.net-mvc-3,Asp.net Mvc,Asp.net Mvc 3,我有一个问题,我的网站登录会话的用户是到期之前的方式应该 这是我的登录方法“ public ActionResult Login(LoginModel model, string returnUrl) { var mcookie = new MyCompanyCookie(); if (ModelState.IsValid) { using (var myRepo = new MyCompanyRepositry()) {
public ActionResult Login(LoginModel model, string returnUrl)
{
var mcookie = new MyCompanyCookie();
if (ModelState.IsValid)
{
using (var myRepo = new MyCompanyRepositry())
{
var passwordHash = MyCompany.Web.Portal.Helpers.Security.CreatePasswordHash(model.Password);
var userAccount = myRepo.GetMyCompanyUser(model.UserName,model.PartnerAccessCode);
if(userAccount != null && userAccount.Password == passwordHash && userAccount.PartnerAccessCode == model.PartnerAccessCode.ToUpper())
{
mcookie.GetMMformsauthentication(userAccount, model.RememberMe);
return RedirectToLocal(returnUrl);
}
else
{
ModelState.AddModelError("", "The user name,access code or password provided is incorrect.");
}
}
及表格认证票:
public void GetMMformsauthentication(UserAccount UserAccount,bool createPersistentCookie)
{
常量字符串UnknownUsername=“匿名”
}
和My Web.config中的过期设置
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
在这里,您可以看到表单过期设置设置为2880分钟,但是用户在大约5-10分钟后就会注销
cookie设置为在100天后过期
有人知道是什么导致了这个问题吗?看来问题不在身份验证标签中的会话中。只要检查一下如果cookies内容被评论会发生什么。。。若会话保留更长的时间,那个么将注意力集中在cookie上
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>