Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with HttpHandler and session state

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.

like image 802
Christopher Klein Avatar asked Apr 10 '26 12:04

Christopher Klein


1 Answers

Did you implement IRequiresSessionState in your handler?

like image 199
CyberDude Avatar answered Apr 12 '26 04:04

CyberDude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!