ASPXAUTH cookie 未保存
我正在开发 ASP .NET MVC 2 中的一个 Web 项目。
在这个项目中,我们将一些信息存储在一个加密的 cookie(ASPXAUTH cookie)中,以避免需要为每个请求查询数据库。
问题是这部分的代码突然停止工作了。
我检查了对源代码控制服务器上的代码所做的更改,以查找可能导致此问题的任何内容,但我什么也没发现。我什至恢复到已知的工作副本(在其他人的 PC 上工作,相同的代码等),但调试后,似乎 .ASPXAUTH cookie 不再保存。相反,正在设置 ASP.NET_SessionId cookie...(之前没有)
我更改了 web.config 文件以关闭 sessionState。这消除了 ASP.NET_SessionId cookie 的设置,但它仍然没有保存身份验证 cookie。
我最近安装了一些 Microsoft Windows XP 更新,但另一个人(他的 PC 运行该应用程序运行得很好)也安装了。
经过谷歌搜索后,我发现一些信息指出了 cookie 过期日期的问题。以太原因是电脑没有正确的时间/日期(事实并非如此),其他原因则是 cookie 过期日期设置错误。 (我检查过,设置正确)...
除了我使用的浏览器(Chrome)之外,其他浏览器仍然存在问题,我用 IE6 尝试过。
关于为什么会发生这种情况有什么想法吗?
我将继续发布我能找到的任何有用信息。
提前致谢。
Im working on a web project in ASP .NET MVC 2.
In this project we store some info inside an ecripted cookie (the ASPXAUTH cookie) to avoid the need to query the db for every request.
The thing is the code for this part has suddenly stopped working.
I reviewed the changes made to the code on the source control server for anything that could be causing it, I found nothing. I even reverted to a known working copy (working on some other persons PC, same code, etc) but after debugging, it seems the .ASPXAUTH cookie is not getting saved anymore. Instead the ASP.NET_SessionId cookie is being set... (wich before wasn't)
I changed the web.config file to turn off the sessionState. This eliminated the ASP.NET_SessionId cookie from being set, but it is still not saving the auth cookie.
Ive recently installed some Microsoft Windows XP Updates, but the other person (whos PC runs the application just fine) also did.
After googling, some info i found pointed out to a problem with the expiration date of the cookie. Ether cus the pc didnt have the right time/date (this was not the case) and others cus of the cookie expiration date being wrongly set. (I checked and it is being set correctly)...
The problem persists with other browsers besides the one im using (Chrome) i tried it with IE6.
Any ideas on why this is happening?
Ill continue to post any helpful information i can find.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是因为你的 cookie 太大了。我遇到了同样的问题。
如果您的 cookie 太大,它就无法工作,当然具体取决于浏览器
MSDN
cookie 通常限制为 4096 字节,每个站点不能存储超过 20 个 cookie。通过使用带有子键的单个 cookie,您可以使用分配给您的网站的 20 个 cookie 中的较少数量。此外,单个 cookie 占用大约 50 个字符的开销(过期信息等),加上存储在其中的值的长度,所有这些都计入 4096 字节的限制。如果您存储五个子项而不是五个单独的 cookie,则可以节省单独 cookie 的开销,并且可以节省大约 200 个字节。
网络浏览器 cookie 的最大大小是多少密钥?
当 cookies 文件超过最大大小时会发生什么?< /a>
This could be that your cookie grew too big. I ran into the same issue.
If your cookie becomes too big, it just won't work, depending on the browser of course
MSDN
cookies are usually limited to 4096 bytes and you can't store more than 20 cookies per site. By using a single cookie with subkeys, you use fewer of those 20 cookies that your site is allotted. In addition, a single cookie takes up about 50 characters for overhead (expiration information, and so on), plus the length of the value that you store in it, all of which counts toward the 4096-byte limit. If you store five subkeys instead of five separate cookies, you save the overhead of the separate cookies and can save around 200 bytes.
What is the maximum size of a web browser's cookie's key?
what happens when cookies file exceeds maximum size?
检查 cookie 大小的一个简单方法是调试并运行以下代码。
如果超出限制,那么您将遇到问题。
An easy way to check your cookies size is to debug and run the following code
If this is over the limit then you will be encountering issues.
在我的情况下,在一定量的头撞墙之后,我注意到在我的工作项目中设置了 cookie,
与我的不工作项目相比,cookie 是手动设置的:
在我的一个共享主机中进行了一些更改后,发生了这种情况我无法弄清楚或通过支持部门找到托管提供商。本地主机或其他共享主机或 vps 在第一个方法中工作得很好
In my case after certain amount of head banging against a wall I noticed in my working projects cookie was set using
in contrast in my not working projects the cookie was being set manually:
This happened in one of my shared hostings after some change was made by hosting provider which I could not figure out or find out through support dep. local host or other shared hostings or vps worked just fine with the first approuch