【发布时间】:2011-04-07 22:07:52
【问题描述】:
我正在尝试设计一种解决方案,该解决方案将模拟 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 或 自定义会话状态模块是 包含在 \
\ 应用程序中的部分 配置。”
我们的所有会话变量都存储在 SQL 中,不确定是否会影响到它。
我见过其他人也有类似的错误,他们得到的答案是您需要添加 ProcessRequest(context) 来解决它。
想法、cmets、建议?
谢谢。
【问题讨论】:
标签: asp.net session httphandler