locked
Obtaining Session State in a IHttpModule or IHttpHandler when a request is for a static file RRS feed

  • Question

  • User1179217401 posted

    Hi.

    We are developing a IHttpModule that requires session state to be available when the pipeline reaches the Process Request stage.

    We use the following :-

    application.PostMapRequestHandler += new EventHandler(SetSessionStateBehavior);

    and in this method we apply the following:-

    application.Context.SetSessionStateBehavior(SessionStateBehavior.Required);

    Which works as expected.

    However, if the request is for a static file, i.e website/image.gif then we assume the static file handler takes over our process request is never reached, so we have replaced the handler for our own  dummy handler that implements the interface IRequiresSessionState, as follows:-

    application.Context.RemapHandler(new PlaceHolderHandler());

    this works but session state is not available for requests that reference a static files.

    Can anyone help resolve this issue. We need a way of forcing session state to be available, regardless of the request URL.

    Regards

    Adrian.

    Saturday, March 9, 2013 6:05 AM

All replies

  • User212506688 posted

    Hi,

    The ASP.NET Handler is not used when requests to static files are made, so that code is likely not executed.

    You might consider adding a global handler (Path = *) that is configured same as an ASPX file (Path = *.aspx).

    Might work, HTH, Benjamin

    Friday, April 12, 2013 10:37 AM