asp.net - HttpHandler 和 session 状态的问题

标签 asp.net session httphandler

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

将 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 中。我现在在我们网站上点击的任何页面都会收到以下错误消息:

"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."

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

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

想法、评论、建议?

谢谢。

最佳答案

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

关于asp.net - HttpHandler 和 session 状态的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3637189/

相关文章:

azure - HTTP HEAD 响应中的 "303 See other"

json - Angular 2 (TypeScript) 处理来自 Http 的空 json 响应

c# - 已配置关系存储,但未指定要使用的 DbConnection 或连接字符串

c# - 在 ASP.NET MVC 中为多语言结构创建表单时需要帮助

php - PHP session 的 iPhone 问题

java - SessionFactory调用openSession抛出noSuchMethoderror异常

javascript - 回发前对表单控件进行 javascript 验证的示例

c# - Silverlight 媒体播放器位置问题

session - 如何安全检测服务中是否存在 session 范围?

asp.net - 删除未使用的 HTTP 处理程序以获得更好的性能和安全性