Accessing SessionState in IHttpModule after 404?
<p>Is it possible to access SessionState in the Error event handler of a HttpModule following a 404?</p>

<p>Im trying to implement a consistent error handling mechanism for both full and partial postbacks using the technique described in this blog post,</p>

<p><a href="http://blogs.microsoft.co.il/blogs/oshvartz/archive/2008/05/17/asp-net-error-handling-using-httpmodule-full-and-partial-post-back-ajax-updatepanel.aspx?CommentPosted=true#commentmessage" rel="nofollow">ASP.NET Error Handling......</a></p>

<p>Instead of passing loads of parameters on the query string im trying to push the exception into session state and access it from the error page.  </p>

<p>SessionState is never available at point I do my Server.Transfer (in error handler of HttpModule) so not available to error page.</p>

<p>Ive tried the trick of resetting the IHttpHandler to one with the IRequestSessionState interface but no joy.</p>

<p>Thanks in advance,</p>

<p>EDIT - The code of the IHttpModule error handler is,</p>

<pre><code>void context_Error(object sender, EventArgs e)
{
    try
    {            
        var srcPageUrl = HttpContext.Current.Request.Url.ToString();                       

        // If the error comes our handler we retrieve the query string
        if (srcPageUrl.Contains(NO_PAGE_STR))
        {
            // Deliberate 404 from page error handler so transfer to error page
            // SESSION NOT AVAILABLE !!!!

            HttpContext.Current.ClearError();                
            HttpContext.Current.Server.Transfer(string.Format("{0}?ErrorKey={1}", ERROR_PAGE_URL, errorKey), true);
        }
        else            
            HttpContext.Current.Server.ClearError();                

        return;
    }
    catch (Exception ex)
    {
        Logging.LogEvent(ex);
    }
}
</code></pre>

<p>Matt</p>
