HttpHandler 和会话状态的问题

发布于 2024-09-17 06:01:21 字数 1317 浏览 10 评论 0原文

我正在尝试设计一个解决方案,该解决方案将模拟 App_Offline.htm 进行远程访问,但仍允许本地用户测试该网站。我发现了一些我正在尝试的选项,但最好的选项似乎不适用于我们的 ASP.NET(2.0) 站点,该站点依赖于在所有页面上启用会话状态。

HttpHandler 添加到 web.config 中

<add verb="*" path="*.aspx" type="AppOffline.AppOfflineHandler, AppOffline" />

,当调用该类时,它归结为:

public void ProcessRequest( HttpContext context )
{
    this.context = context;

    // offline mode and remote request?
    if ( !context.Request.IsLocal &&
        IsOffline
        )
    {
        context.Response.Clear();
        context.Response.Write( AppOffline );

        context.Response.End();
    }
    else
        // redirect to the default processing pipe
        PageParser.GetCompiledPageInstance(
            context.Request.Path,
            context.Request.PhysicalPath,
            context ).ProcessRequest( context );
}

问题出在 PageParser.GetCompiledPageInstance 中。我现在在我们网站上点击的任何页面都会收到以下错误消息:

“会话状态只能在以下情况下使用: enableSessionState 设置为 true, 在配置文件中或在 页面指​​令。还请使 确定 System.Web.SessionStateModule 或 自定义会话状态模块是 包含在 <配置>\<系统.web>\< http模块> 应用程序中的部分 配置。”

我们将所有会话变量存储在 SQL 中,不确定这是否会影响其中。

我见过其他人也遇到过类似的错误,他们得到的答案是您需要添加 ProcessRequest(上下文)来解决它的

想法,评论,建议

I'm trying to fashion a solution which will simulate App_Offline.htm for remote access but still allow local users to test the website out. I found some various options that I am trying out but the best one doesn't seem to work for our ASP.NET(2.0) site which relies on session state being enabled on all of the pages.

The HttpHandler is added into web.config

<add verb="*" path="*.aspx" type="AppOffline.AppOfflineHandler, AppOffline" />

and when the class is called, it boils down to this:

public void ProcessRequest( HttpContext context )
{
    this.context = context;

    // offline mode and remote request?
    if ( !context.Request.IsLocal &&
        IsOffline
        )
    {
        context.Response.Clear();
        context.Response.Write( AppOffline );

        context.Response.End();
    }
    else
        // redirect to the default processing pipe
        PageParser.GetCompiledPageInstance(
            context.Request.Path,
            context.Request.PhysicalPath,
            context ).ProcessRequest( context );
}

The problem is in PageParser.GetCompiledPageInstance. Any page that I hit now within our website I get the following error message:

"Session state can only be used when
enableSessionState is set to true,
either in a configuration file or in
the Page directive. Please also make
sure that
System.Web.SessionStateModule or a
custom session state module is
included in the
< configuration>\< system.web>\< httpModules>
section in the application
configuration."

We have all of our session variables stored within SQL, not sure if that factors into it or not.

I've seen other people who have had similar errors and the answer they were given was that you needed to add the ProcessRequest(context) to get around it.

thoughts, comments, suggestions?

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

活雷疯 2024-09-24 06:01:21

您是否在处理程序中实现了 IRequiresSessionState

Did you implement IRequiresSessionState in your handler?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文