c# - HttpContext.Current.Session 给出 StackOverflowException?

标签 c# asp.net-mvc asp.net-mvc-3 .net-4.0

我在 Global.asax.cs 中以下代码片段中突出显示的代码行上收到 StackOverflowException,有人可以告诉我为什么会发生这种情况吗?

代码:

public static HttpSessionState CurrentSession
        {
            get
            {
                if (HttpContext.Current == null)
                    return null;
                return HttpContext.Current.Session;
            }
        }

谢谢, 亚历克斯。

最佳答案

事实上答案是: “你的堆栈溢出没有发生在这里。也许发布调用它的代码 --- 堆栈溢出中涉及的代码(因为你可能从几个地方调用它)。 – Eben Roux 6 月 30 日 4: 37"

它出现在请求 CurrentSession 的代码中,但这只是它中断的行。

关于c# - HttpContext.Current.Session 给出 StackOverflowException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6529494/

相关文章:

c# - WPF Clickonce 使用 Microsoft.Net.Sdk 发布

c# - WPF 列表框 : Change border per item according boolean value

asp.net - 将 MVC 2 项目升级到 MVC 5

c# - 启用双重转义是否危险?

c# - 在 asp.net 中创建日期时间选择器

asp.net-mvc - ASP.NET MVC - View 模型、域模型和数据模型

c# - 多线程错误 : There is already an open DataReader associated with this Connection which must be closed first

c# - 在我的 MVC3 应用程序中使用 jQuery 自动完成

asp.net-mvc - 如何从 ASP.NET MVC 中的 JSONResult 方法重定向到 Controller 操作?

asp.net-mvc-3 - N 层服务层验证显示表示层中的业务逻辑错误