gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 14:16:22 25 4
gpt4 key购买 nike

我正在尝试设计一个解决方案,该解决方案将模拟 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com