C# IHttpHandler并继续使用PageParser.GetCompiledPageInstance分页
我试图做一个简单的HttpHandler来检查一些事情(安全性——尽管这并不重要),然后继续页面。这应该很简单,但我显然有1个或两个参数来获取CompiledPageInstance不正确:C# IHttpHandler并继续使用PageParser.GetCompiledPageInstance分页,c#,asp.net,httphandler,ihttphandler,C#,Asp.net,Httphandler,Ihttphandler,我试图做一个简单的HttpHandler来检查一些事情(安全性——尽管这并不重要),然后继续页面。这应该很简单,但我显然有1个或两个参数来获取CompiledPageInstance不正确: public void ProcessRequest(HttpContext context) { if (CheckAccess(context)) PageParser.GetCompiledPageInstance(context.Request.Path, context.R
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" />
在处理程序中实现IRequiresessionState尝试:
PageParser.GetCompiledPageInstance(context.Request.Path, context.Request.PhysicalPath, context )
.ProcessRequest( context );
我相信GetCompiledPageInstance中的第二个参数只需要是文件名,而不是文件名和路径。尝试使用System.IO.Path.GetFileName(context.Request.PhysicalPath);