InProc会话数据disapearing [英] InProc session data disapearing

查看:192
本文介绍了InProc会话数据disapearing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只注意到这个大约一个星期前。我存储有关当前的难题该用户正在播放(www.wikipediamaze.com)这样的数据:

I just noticed this about a week ago. I'm storing data about the current puzzle a user is playing (www.wikipediamaze.com) like this:

HttpContext.Current.Session.Add(puzzleInfo,currentPuzzleInfo);

HttpContext.Current.Session.Add("puzzleInfo", currentPuzzleInfo);

我知道,在使用是InProc模式会话存储数据非常不稳定,会重置每当web.config中的变化或任何其他因素,包括回收应用程序池。

I know that storing data in the session using the "InProc" mode is very volatile and will get reset whenever the web.config changes or any number of other factors including recycling the app pool.

但是我的数据在一个时间只停留几秒钟(该时间是可变的,但字面上不长的话),然后消失。我在一个共享的托管环境,所以我不知道这是否将有什么关系呢。

However my data is only staying for a few seconds at a time (the time is variable but literally not long at all) and then disappearing. I'm in a shared hosted environment so I don't know if that would have anything to do with it.

任何想法是怎么回事?我会过得更好只需直接将其存储在客户端作为cookie吗?请帮助。

Any idea what's going on? Would I be better off just storing it directly on the client as a cookie? Please help.

谢谢!

推荐答案

故障排除

丢失数据每隔几秒钟是不寻常的,但也可能会被你的共享主机提供商的一个问题 - 听起来像服务器不断下降出于某种原因会议。您可以显示会话ID(Session.SessionID),看看它的变化。

Losing data every few seconds is unusual, there could possibly be a problem with your shared hosting provider -- sounds like the server is constantly dropping sessions for some reason. You could display the sessionID (Session.SessionID) and see if it changes.

有可能是一个进程崩溃事情,引起别人的服务器上的其他人。下面是关于故障排除这类问题的一个MSDN博客文章(向下滚动的途中经过约25%)的http://blogs.msdn.com/webtopics/archive/2009/07/22/in-proc-session-state-management.aspx

There could be a process crash going on, caused by someone else on the server. Here's an msdn blog post on troubleshooting this type of problem (scroll down about 25% of the way through): http://blogs.msdn.com/webtopics/archive/2009/07/22/in-proc-session-state-management.aspx

这不会有太大的帮助,你在共享主机环境,但你可以通过它的支持链。也许他们可以看看事件日志,并确定谁是打破IIS,并给他们引导。

This won't be much help to you in a shared hosting environment, but you could pass it up the support chain. Maybe they could look at the event logs and determine who is breaking IIS and give them the boot.

正如肖恩·麦克唐纳说:

As stated by Sean McDonough:

...鉴于您在共享主机是
  环境,有一个像样的机会
  有一个以上的网络服务器
  托管您的网站。如果有多个服务器
  是服务您的网站和负载
  平衡机制是在使用中该
  不保持任何形式的会议
  亲,你可以简单地反弹
  到不同的Web服务器,并启动
  一个新的会话;毕竟,在进程内
  会议是不会跟着你
  跨框。

...given that you're in a shared hosting environment, there's a decent chance that there is more than one web server hosting your site. If multiple servers are serving up your site and a load balancing mechanism is in-use that doesn't maintain any sort of session affinity, you could simply be bouncing to a different web server and starting a new session; after all, in-proc session is not going to follow you across boxes.

作为国家持久性的替代品

在任何情况下,我一直觉得是InProc甚至可以说在专用服务器上间歇性不可靠的,所以我避免它。

At any rate, I have always found InProc to be intermittently unreliable even on dedicated servers, and so I avoid it.

要与饼干谨慎 - 饼干相处每个请求(图片,脚本等)发送,应保持到最低限度。你可能会认为,咩,这个项目并不需要扩展,但一旦你做,你要使用的cookies,以保存状态的项目范围内的设计决策,你游弋一个众所周知的瘀伤。

Be cautious with cookies -- cookies get transmitted along with each request (images, scripts, etc) and should be kept down to the bare minimum. You may think, "Meh, this project doesn't need to scale," but once you make the project-wide design decision that you're going to use cookies to persist your state, you are cruising for a proverbial bruising.

和我的意思是,你走出的最佳做法,并可能会碰到一些丑陋的情况下,这样的时候,我需要坚持第二的XML文档。那会不会是在cookie一个好主意!

And by that I mean, you are stepping out of best practices and may run into some ugly situations, like that time I needed to persist an xml document for a second. That would not be a good idea in a cookie!

如果你没有办法设置会话状态服务器(这是很容易的方式),因为你在共享主机环境的时候,你可以看看SqlSessionStateStore,它可以让您保存在您的会话数据一个SQL Server。

If you don't have a way to set up session state server (which is really easy by the way) because you're in a shared hosting environment, you could look into SqlSessionStateStore, which lets you store your session data in a SQL Server.

这篇关于InProc会话数据disapearing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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