Question

I am trying to do a simple HttpHandler that checks some things (security - though this is unimportant) and continue on to the page. It should be simple, but I obviously have 1 or both parameters to GetCompiledPageInstance incorrect:

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;
}

This is a website, not application, though I don't think that makes a difference.

When I add the handler code to the web config

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

Now I get an error that I did not get prior to adding it (no other changes):

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 \\ section in the application configuration.

Never mind. Found the answer to this 2nd part: Problem with HttpHandler and session state

implement IRequiresSessionState in the handler

Was it helpful?

Solution

Try:

    PageParser.GetCompiledPageInstance(context.Request.Path, context.Request.PhysicalPath, context )
         .ProcessRequest( context );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top