失去我的会话变量 - 什么异常可能导致会话丢失? [英] Losing my session variables - What exception might cause sessions to be lost?

查看:112
本文介绍了失去我的会话变量 - 什么异常可能导致会话丢失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生产系统上启用健康监测(asp.net web表单.NET 4中),我看到有很多已经发送给我的错误,表明一个会话变量已丢失的。

I have health monitoring enabled on a production system (asp.net webforms .net 4) and I see that there's a lot of errors being sent to me indicating that a session variable has been lost.

(我试图连接东西出来会话状态的一个实体框架数据上下文,并得到一个值不能为空,参数名实体的错误)。所以,在某种程度上会话变量现在包含空值,而不是一个对象。

(I am trying to attach something out of session state to a entity framework data context and get a "Value cannot be null, parameter name entity" error). So somehow the session variable now contains null and not an object.

有趣的是,我们有部署在两个单独的服务器相同的应用程序 - 一个DMZ服务器外部用户和内部用户一个内部服务器。两个在两个不同的服务器这些应用似乎有相同的问题。

Interestingly we have the same application deployed on two separate servers - one DMZ server for external users and one internal server for internal users. Both of these applications on two different servers seem to have the same problem.

健康监测也一辈子监控事件和我由此可以看出,我们没有像IIS回收,配置的改变,对bin文件夹,重新编译等,发生的历史。

Health Monitoring is also monitoring lifetime events and I can see from this that we do not have something like IIS recycling, config changes, changes to bin folder, recompilations etc, occuring.

我已经阅读此页:<一href=\"http://weblogs.asp.net/bleroy/archive/2004/08/03/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_.aspx\" rel=\"nofollow\">http://weblogs.asp.net/bleroy/archive/2004/08/03/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_.aspx

我可以证实,这不是一个Response.Redirect的问题,因为没有发生 - 这是一个在线申请表 - 它把一个对象在会话状态的Page_Load中,有一个多视图 - 当下一个是pressed,对象出来会话状态的,附加到数据上下文,更改从Web表单并更新了的datacontext制成。所以没有Response.Redirect的发生。

I can confirm that it's not a Response.Redirect problem because that's not happening - this is an online application form - it puts an object in session state on page_load and there's a multiview - when "next" is pressed, the object comes out of session state, is attached to the data context, changes are made from the web form and the datacontext updated. So there's no response.redirect happening.

我还可以确认在更新1的细节,并从该链接更新2与我无关 - 只有1中的应用程序池和服务器名称或网址不包含下划线运行工作进程

I can also confirm the details in "Update 1" and "Update 2" from that link are not relevant to me - there is only 1 worker process running in the application pool and the server name or web address do not contain underscores.

我也想追寻会议的可能性,超时存在的,但他们应该由运行检测会话超时(看其他code处理:<一href=\"http://blogs.msdn.com/b/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx ),我已经测试了个遍 - 部分问题是我不能重现这个错误我自己

I also persued the possibility of session timeouts occuring but they should be handled by other code which is running to detect session timeouts (see: http://blogs.msdn.com/b/nikhiln/archive/2007/06/21/detecting-session-timeout-in-asp-net-2-0-web-applications.aspx ) which I have tested over and over - Part of the problem is I just cannot reproduce this error myself.

所以: - 结果
- 不超时结果
- 而不是IIS工作进程回收或会产生健康监测一辈子的大事任何其他东西结果
- 不使用Response.Redirect的结果
- 没有一个Web农场/多个工作进程

So:-
- Not timeouts
- Not the IIS worker process recycling or any other thing which would generate a Health Monitoring lifetime event
- Not using response.redirect
- Not got a web farm/multiple worker processes

然后我发现这个线程: http://bytes.com/专题/ ASP-NET /答案/ 490975-消失的会话凡MVP说以下内容:

I then found this thread: http://bytes.com/topic/asp-net/answers/490975-disappearing-sessions where an MVP said the following:

每当IIS应用程序是
  重新启动后,所有会话重新启动
  太。所以,是的,这通常会
  发生在重新编译以及一些
  大未处理的应用水平
  例外情况。

Anytime the IIS application is restarted, all sessions are restarted too. So yes, this would generally happen during recompilations and some major unhandled application level exceptions.

但遗憾的是并没有详细说明是什么样的重大未处理的应用程序级异常可能会导致会话丢失 - 这是一个全新的系统,而我们仍然有我们正在修复工作未处理产生的异常 - 那么什么样的例外,我们这里所说的?在一个人的会话的应用异常可以真正删除应用程序持有的所有会话?

But sadly didn't elaborate what sort of "major unhandled application level exceptions" might lead to session loss - this is a brand new system and we do still have unhandled exeptions that we're working on fixing - so what sort of exceptions are we talking about here? Can an application exception in one person's session really delete all sessions held by the application?

这线程也触动它: http://bytes.com /主题/ ASP-NET /答案/ 490975-消失的会话

我见过类似的唯一事情是
  当在发生运行时错误
  ASP.NET应用程序,从而导致
  应用程序重新启动。你是
  Application_OnStart的接收事件
  呢?

The only thing I've seen similar is when a runtime error occurs in the ASP.NET application, causing the application to restart. Are you receiving Application_OnStart events too?

所以我猜,如果我有导致重新启动应用程序运行时错误,这也将产生一个健康监测一辈子的大事,对不对?而我只是没有得到任何的那些...

So I'm guessing if I had a runtime error that caused the application to restart, that would also generate a health monitoring lifetime event, right? And I'm just not getting any of those...

这将是一个容易得多,如果我能真正瑞普这一点,但我不能!

It would be a lot easier if I could actually repro this but I just cannot!

长期rambly问题反正对不起,只是希望有人有一些想法。

Anyway sorry for a long rambly question, just hope somebody has some ideas.

问候

推荐答案

你有没有考虑把会话状态的应用程序之外,例如与任何asp.net 出的进程为会话状态?

Did you consider placing session state outside the app, e.g. with any of the asp.net out-of-process modes for session state?

在默认情况下,会话状态保持你的应用程序中。这不是在多台服务器可用,也不是维护整个应用程序崩溃(在你的应用程序,即任何未处理的异常。)

By default, session state is maintained inside your app. It is not available across multiple servers, nor is it maintained across application crashes (i.e. any unhandled exceptions in your app.)


  1. 使用SQL Server模式,使其在多台服务器提供相同的会话状态。

  1. Use the SQL Server mode to make the same session state available across multiple servers.

另外,如果你的负载平衡器担保强大的会话亲缘关系,您可以使用asp.net状态服务器来管理状态,每个服务器的方式,让国家生存的应用程序重新启动。

Alternatively, if your load balancer guaranties strong session affinity, you can use the asp.net state server to manage state in each server in a way that lets state survive application restarts.

这篇关于失去我的会话变量 - 什么异常可能导致会话丢失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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