global.asax : Application_Error and Session don't work

B

BenCoo

In my ASP.NET 2.0 application I have in the global.asax.file the following
code

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
This dousn't work !!! Get error "Session state is not available in this
context."
Dim ex As Exception
ex = Server.GetLastError.InnerException
Session("Exception") = ex
Session("FilePath") = Server.MapPath(Me.ToString)
Response.Redirect("ErrorPage.aspx")
End Sub

I've get the error "Session state is not available in this context." when
there's an error on a page ...

Thanks for any help on this ...

Benny
 
B

BenCoo

Thanks, but didn't find a solution while the aspx-page where this error is
generated is in a subdirectory
 
J

Juan T. Llibre

Are you using code-behind ?

If so, you need to use HttpContext.Current
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top