Session ID changes in each Request

大憨熊 提交于 2021-02-20 04:55:40

问题


I have an asp.net application in which i redirect from one page to another. I'm validating the SessionID in the second page to make sure both requests are of the same session. Now, my problem is the SessionID changes whenever a Postback is happened.

Now, I added the Session tag into my web.config

<sessionState mode="InProc" cookieless="true"/>

Now, the problem with the session was solved and a new issue started appearing. Whenever i make a call with Cookiless="true" in my web.config file, my URL shows a junk address

http://localhost:10766/(S(ojbcobj0aw0wiosttgpknwby))/registration.aspx

If I remove the Cookieless tag the session will be lost in the next page? Do anyone know why is this coming and if any fix is there for this problem?


I went through lot of threads but i couldn't find a proper fix for this.


EDITED: I Set my cookieless="false" and now its working fine.


回答1:


.NET Framework has 05 (five) session state modes:

  • InProc mode, which stores session state in memory on the Web server. This is the default.
  • StateServer mode, which stores session state in a separate process called the ASP.NET state service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
  • Custom mode, which enables you to specify a custom storage provider.
  • Off mode, which disables session state.

Now i need to know exactly what does your application do to recommend the better solution:

  1. Do you store something in Session?
  2. Are you using multithreading?
  3. How many servers your farm will have (when the application go live)
  4. Does your app connect to database?

If you keep your original web.config, by default your application will use InProc mode and will store session id on cookie, unless your browser or local server denied it.

I'm waiting to the answers to complement my post.

Reference: http://msdn.microsoft.com/en-us/library/ms178586.ASPX



来源:https://stackoverflow.com/questions/22038655/session-id-changes-in-each-request

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