为什么HttpContext.Current.Session正在改变evertime我访问同一页面ASP.Net [英] Why HttpContext.Current.Session is changing evertime I visit the same page ASP.Net
问题描述
下面的情景
我有一个网页,可以说有一个叫做登录按钮login.aspx的,那个按钮的点击事件,当我检查的SessionID它显示了一个特定的值,例如A
I have a page lets say login.aspx having a button called login, on click event of that button when I check for the SessionID its shows a specific value for example "A"
现在我正在调用一些外部网页,然后该网页再次调用这个页面。
Now I am making a call to some external page and that page then calls this page again.
比如说我一旦点击登录按钮,我叫Twitter的应用程序,当用户授予它,我重定向到同一个页面,但现在当我访问的SessionID它的一个新的ID。
for instance once I click login button I call a twitter app and when user authorizes it, I am redirected back to the same page, but now when I am accessing the SessionID its a new ID.
我不知道为什么会这样,我只是想有相同的SessionID
I have no idea why this is happening, I just want to have the same SessionID
推荐答案
您不必在多个Web服务器,你呢?
You don't have multiple web servers, do you?
如果是这样,如果你不使用共享会话状态提供者,你往往会看到这种行为。
If so, and if you're not using a shared session state provider, you'd tend to see this kind of behaviour.
编辑。
OK,下一个问题......
OK, next question...
是Twitter的授权返回使用完全相同的域名的URL?
Is the URL that the Twitter authorisation is returning to using exactly the same domain name?
例如,如果你的应用程序在运行 http://127.0.0.1:1234/ 和返回URL是的http://本地主机:1234 /
For example, if your application is running on http://127.0.0.1:1234/ and the return URL is http://localhost:1234/ ?
EDIT2:是的。
当你从127.0.0.1的Twitter的应用程序重定向,ASP.NET的会话cookie没有被传递回Web服务器,因为域名是不同的。
When you are redirected back from the Twitter app on 127.0.0.1, the ASP.NET session cookie isn't being passed back to the web server because the domain is different.
您需要的应用程序在其下运行相匹配的Twitter的回调URL的域。
You need the domain that the app is running under to match the Twitter callback URL.
重新配置Twitter的回调URL为localhost:1234,我想你应该确定
Reconfigure the Twitter callback URL to localhost:1234 and I think you should be OK.
这篇关于为什么HttpContext.Current.Session正在改变evertime我访问同一页面ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!