找出为什么asp.net身份验证票据过期 [英] figuring out why asp.net authentication ticket is expiring
问题描述
我需要帮助找出我的身份验证票据在我的托管网站上大约一个小时后到期的原因。
I need help figuring out why my authentication ticket is expiring after about an hour on my hosted website. But if I run the site locally the authentication ticket stays alive for the correct amount of time.
这是我的本地主机web.config:
This is my localhost web.config:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="20160" slidingExpiration="true" path="/" />
</authentication>
这是我托管的web.config:
and this is my hosted web.config:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="20160" slidingExpiration="true" domain=".mywebsite.com" path="/" />
</authentication>
我知道身份验证票据正在创建,因为:
I know the authentication ticket is being created because:
- 我可以在浏览器Cookie中查看
- 即使关闭浏览器并重新打开后,我仍然保持登录
- 我在网站回收后仍保持登录状态(更改并保存web.config以回收邮件)
日期在浏览器它的2个星期后。但是,大约一个小时后,我的身份验证总是会过期。
When I check the cookie expiration date in the browser it's 2 weeks later. However, after about an hour my authentication always expires.
我该怎么做才能找出为什么托管网站的身份验证过早到期?
我不知道如何解决这个问题,因为它是我的托管网站,是唯一有问题的。
What can I do to figure out why the hosted website's authentication is expiring so early? I don't know how to go about resolving this problem since it's my hosted website that is the only one having problems.
更新1:等待1小时后,我检查浏览器,我看到cookie仍然存在。事实上,它的过期日期设置为2周后。但是,如果我重新载入网页或尝试访问任何需要身份验证的网页,我会进入登录页面。
Update 1: After waiting 1 hour, I check my browser and I see the cookie still exists. In fact it's expiration date is set for 2 weeks later. But if I reload the page or try going to any pages that requires authentication I am taken to the login page.
推荐答案
在system.net中的machinekey条目。类似这样的:
I added a machinekey entry in system.net. Something like this:
<machineKey validationKey="aaa"
decryptionKey="bbb" validation="SHA1" />
现在它保持用户已登录。但现在看起来我遇到了性能问题。现在花费大约500毫秒来加载的页面大约是该时间的两倍。
and now it keeps the user logged in. However, now it seems like I am having performance issues. The page used to take roughly 500ms to load now takes about double that time.
这篇关于找出为什么asp.net身份验证票据过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!