在ASP.NET C#中丢失会话 [英] Losing session in ASP.NET C#

查看:125
本文介绍了在ASP.NET C#中丢失会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上丢失会话变量的问题。将其追加在随机时间,所以没有特别的行为,导致此。有什么可以这届丢失的原因是什么?

I'm having a problem of losing session variable on my website. It append at random times so there is no particular behavior that cause this. What can be the cause of this session lost?

我读过到处都在这个网站,所以一切在服务器上写的,我可以把我的会议的SQL Server模式,它可以是一个解决办法?

I've read everywhere on this site that I could put my session in "sql server" mode so everything is written on the server, can it be a solution?

我的服务器上的1and1共享主机,也可以是他们的错?

My server is on 1and1 shared hosting, can it be their fault?

谢谢!

推荐答案

请与您的应用程序没有被一个负载平衡服务器上托管的托管服务提供商。如果服务器正在负载均衡,当负载平衡器发送他们的请求到另一个服务器用户将丢失其会话状态信息。有3个设置会话状态模式属性:
是InProc - 将在本地存储从中提出要求(唯一有效的当应用程序在单一服务器上在非负载均衡环境中托管)在服务器上的状态信息
的StateServer - 允许一个特别配置的服务器托管状态信息为整个Web农场(我相信的StateServer开始的.NET Framework 2.0中提供)。
的SqlServer - 允许一个特别配置的SQL Server实例来存储会话信息的Web场
[此信息将有所不同在Web花园情景略低。]

Check with the hosting provider that your application is not being hosted on a load balanced server. If the server is being load balanced, your users will lose their session state information when the load balancer sends their request to another server. There are 3 settings Session State mode property: InProc - Will store state information locally on the server from which the request is made (only effective when the application is being hosted on a single server in a non-load balanced environment) StateServer - Allows a specially configured server to host state information for an entire web farm (I believe StateServer began to be offered on .NET Framework v2.0). SqlServer - Allows a specially configured SQL Server instance to store session information for a web farm [This information will vary slighty in a web garden scenario.]

请参阅 MSDN 关于会话状态的更多信息。

See MSDN for more information on Session State.

这可以根据自己的负载平衡设置(认为:粘性负载平衡)非常随机地发生。而且可以工作几分钟一次,失败几乎立刻其他时间

This can happen very randomly based on their load balancing settings (think: sticky load balancing) and can work for several minutes one time and fail almost immediately another time.

另一种可能性是在web.config中的sessionState设置的超时属性被设置为较低的值(它是分钟)和会话过期。

The other possibility is the timeout property of the sessionstate setting in the web.config has been set to a low value (it is in minutes) and the session is expiring.

这篇关于在ASP.NET C#中丢失会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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