每个请求中的会话ID更改 [英] Session ID changes in each Request

查看:93
本文介绍了每个请求中的会话ID更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net应用程序,在其中我从一个页面重定向到另一页面.我正在第二页中验证 SessionID ,以确保两个请求都属于同一会话.现在,我的问题是每当回发时SessionID都会更改.

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.

现在,我将Session标记添加到了 web.config

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

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

现在,该会话的问题已解决,并且开始出现新的问题.每当我在 web.config 文件中使用 Cookiless ="true" 进行呼叫时,我的URL就会显示垃圾地址

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

如果删除 Cookieless 标记,会话将在下一页丢失吗?有人知道为什么会这样吗?是否有针对此问题的解决方案?

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.

我设置了 cookieless ="false" ,现在可以正常使用了.

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

推荐答案

.NET Framework具有05(五种)会话状态模式:

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

  • InProc模式,它将会话状态存储在Web服务器上的内存中.这是默认设置.
  • StateServer模式,该模式将会话状态存储在称为ASP.NET状态服务的单独进程中.这样可以确保在重新启动Web应用程序时保留会话状态,并使会话状态可用于Web场中的多个Web服务器.
  • SQLServer模式将会话状态存储在SQL Server数据库中.这样可以确保在重新启动Web应用程序时保留会话状态,并使会话状态可用于Web场中的多个Web服务器.
  • 自定义模式,它使您可以指定自定义存储提供程序.
  • 关闭模式,它会禁用会话状态.
  • 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. 您是否在会话中存储了某些内容?
  2. 您正在使用多线程吗?
  3. 您的服务器场将拥有多少服务器(当应用程序上线时)
  4. 您的应用是否连接到数据库?

如果您保留原始的web.config,则默认情况下,您的应用程序将使用InProc模式,并将会话ID存储在Cookie上,除非您的浏览器或本地服务器拒绝它.

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.

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

这篇关于每个请求中的会话ID更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆