虽然与的global.asax.cs 文件玩弄我附加了一些code里面的
While playing around with the global.asax.cs file I attached some code inside of
protected void Session_Start(object sender, EventArgs e) { },然后开始注意到,在session_start 使用Chrome时正被每个请求调用。当使用火狐,这种情况并非如此,它只是调用一次。可能是什么原因?
and then started to notice that Session_Start was being called at every request when using chrome. When using firefox, this was not the case and it was only called once. What could be causing this?
要注意,这只是我的dev的机器。我编译和运行code,打开Firefox,浏览到的http://本地主机:63893 / 和它击中在session_start 。而在Firefox浏览它只击中在session_start 一次。
To note, this is only on my dev machine. I compile and run the code, open firefox, browse to localhost:63893/ and it hits Session_Start. While browsing in firefox it only hits Session_Start once.
当我打开Chrome,浏览到的http://本地主机:63893 / 它击中在session_start 。接着我输入我的登录数据和命中登录,然后它击中在session_start 另一个时间,然后它击中在session_start 另一个的时间,同时加载下一个页面的GET请求。我用了一个柜台看到,事实上,3个独特的会议分别在此期间创建的。
When I open chrome and browse to localhost:63893/ it hits Session_Start. Then I enter my login data and hit login, and it hits Session_Start another time, and then it hits Session_Start another time while loading the get request for the next page. I used a counter to see, and in fact 3 unique sessions were created during that time.
我知道还是有一些状态,当没有值存储在其会话被放弃的来源。这将在这里罚款解释对我来说,却并非如此。我反驳这两个方法。
I know that there are some sources which state that a Session is abandoned when no value is stored in it. That would be a fine explanation here for me, but it is not the case. I disproved this from two methods.
方法1:
protected void Session_End(){} /*breakpoint*/从不解雇,我可以证实,旧会话仍present。
Never fired, and I can confirm that the old sessions are still present.
方法2:
用于会话[的KeepAlive] =真; 在session_start 里面,看看是否会prevent _Start 被调用,但事实并非如此。 _END 仍然没有被调用。
Used Session["KeepAlive"] = true; inside of Session_Start to see if that would prevent _Start from being called but it did not. _End was still not called.
什么是两个或我做了什么错误之间如此不同?
What is so different between the two or what have I done wrong?
推荐答案感谢您的评论所有帮助。的tobiefysh.blogspot.co.uk/2010/12/chrome-is-eating-my-session-varibles-or.html
Thanks for all the help in comments. We actually resolved this in chat and through a link to a blog post: tobiefysh.blogspot.co.uk/2010/12/chrome-is-eating-my-session-varibles-or.html
这说明了有试图去的favicon.ico 时,302响应。基本上,铬请求favicon.ico的,它被击中的RegisterRoutes 方法,并使它成为它创建在session_start 方法过多的会话。
It explains that there was a 302 response when trying to get to favicon.ico. Basically, chrome is requesting favicon.ico, it is hitting the RegisterRoutes method and making it into the Session_Start method which creates excessive Sessions.
这使得它一路在session_start 的原因是因为的的ID = 114082相对=nofollow>谷歌浏览器不发送的cookie。所以,所有那些谁虽然这是一个cookie的问题:你是对的。
The reason it makes it all the way to Session_Start is because google chrome does not send cookies with favicon requests. So, to all those who though it was a cookie issue: you were right.
pretty简单的解决所有烦恼,只是增加了这对我的的RegisterRoutes 法
Pretty simple fix for all the annoyance, just added this to my RegisterRoutes method
routes.IgnoreRoute("favicon.ico");现在谷歌不再是他们想要我的图标,每次获得一个会话。
Now google no longer gets a session every time they want my icon.
更多推荐
铬在session
发布评论