Does ASP .NET Session reset after login?

怎甘沉沦 提交于 2019-12-11 05:40:00

问题


EDIT

This problem seems to have strangely disappeared. There must've been something funky with my environment. I'm voting to close this question.


When a user logs in, I inflate the session with a bunch of data from the Login page code-behind. Then I redirect the user to a different page in the application. I also have some session recovery logic which re-inflates the session based on the auth ticket when the user's session expires.

What seems to be happening is that I inflate the user's session with a bunch of data from the login page, then redirect them, and the request for the page to which I redirect them doesn't seem to have the session, so the application has to re-inflate it. I don't understand this - I've looked at the cookie and the session ID is not changing, and I am not resetting the session data anywhere in the code. Is this an ASP .NET 'feauture'? I'm using ASP .NET 4.0.

Edit:

To clarify: The session is inflated during the login request (on the click even of the login button). During the next request, it doesn't appear the session is populated any longer, so I end up having to re-inflate the session. Any requests that user makes after that, the session seems to "stick" and I have the properly inflated session for subsequent requests.


回答1:


To answer your question SessionState data is independent of login/logout.

There are several reasons why data might "disappear" from SessionState.

  • If you are using InProc SessionState on a web farm, the user may have a subsequent request be served by a different machine in the farm.
  • SessionState can clear if it gets too full (like a cache).
  • If you are using a custom SessionStateStoreProvider, it may not be saving/retrieving the SessionState properly.


来源:https://stackoverflow.com/questions/6293159/does-asp-net-session-reset-after-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!