我已经在mvc.net项目中使用了表单身份验证,并且工作正常,cookie设置在浏览器中,有效期为一年,但是当我尝试在几小时后访问该页面后,我不得不登录页面再次不考虑活动cookie。
仅当将代码部署在服务器中时,才会发生此问题,请在此共享您的输入。
在验证用户身份后,在我的C#代码中,我使用下面的代码行设置Cookie,
FormsAuthentication.SetAuthCookie(username, true);
和我的web.config
<authentication mode="Forms">
<forms name="_ac" loginUrl="/login" timeout="525600" defaultUrl="/"
slidingExpiration="false"></forms>
</authentication>
它可以在我的本地环境中工作,但是在开发服务器中部署后却无法正常工作,会话将在几分钟内过期,并迫使用户登录。
谢谢
Ram