HttpHandler 和会话状态的问题
我正在尝试设计一个解决方案,该解决方案将模拟 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在处理程序中实现了
IRequiresSessionState
?Did you implement
IRequiresSessionState
in your handler?