2013-03-17 68 views
0

我想做一个简单的HttpHandler检查一些事情(安全 - 虽然这是不重要的),并继续到页面。它应该是简单的,但我显然有1个或两个参数来GetCompiledPageInstance不正确:IHttpHandler并继续与PageParser.GetCompiledPageInstance页

public void ProcessRequest(HttpContext context) 
{ 
    if (CheckAccess(context)) 
     PageParser.GetCompiledPageInstance(context.Request.Path, context.Request.PhysicalPath, context); 
} 

public bool IsReusable { get { return false; } } 

private bool CheckAccess(HttpContext context) 
{ 
    return true; 
} 

这是一个网站,而不是应用程序,但我不认为这有差别。

当我处理程序代码添加到web配置

<add name="SecurityHandler" verb="*" path="*.aspx" type="SecurityHandler" /> 

现在,我得到的是我之前没有加入它(无其他变动)得到一个错误:

会话状态可以仅在enableSessionState设置为true时使用,无论是在配置文件中还是在Page指令中。请确保System.Web.SessionStateModule或自定义会话状态模块包含在应用程序配置的\\部分中。

没关系。发现这个问题的答案第2部分:Problem with HttpHandler and session state

实施IRequiresSessionState在处理

+0

相信在GetCompiledPageInstance的第二个参数必须是文件名,而不是文件名和路径。尝试使用System.IO.Path.GetFileName(context.Request.PhysicalPath); – David 2013-03-17 21:13:00

回答

1

尝试:

PageParser.GetCompiledPageInstance(context.Request.Path, context.Request.PhysicalPath, context) 
     .ProcessRequest(context); 
+0

这似乎工作,但请参阅上面的编辑会话。 – 2013-03-18 22:00:45