By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 1,579 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

global.asax : Application_Error and Session don't work

P: n/a
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
Jun 3 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
Thanks for any help on this ...
Google is your friend:
http://www.google.co.uk/search?sourc...his+context%22
--
http://www.markrae.net

Jun 3 '07 #2

P: n/a
Thanks, but didn't find a solution while the aspx-page where this error is
generated is in a subdirectory
"Mark Rae" <ma**@markNOSPAMrae.netschreef in bericht
news:un**************@TK2MSFTNGP04.phx.gbl...
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
>Thanks for any help on this ...

Google is your friend:
http://www.google.co.uk/search?sourc...his+context%22
--
http://www.markrae.net

Jun 3 '07 #3

P: n/a
Are you using code-behind ?

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

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
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


Jun 3 '07 #4

P: n/a
Also, check out this blog :

http://blogs.gotdotnet.com/mattwag/a...07/368605.aspx

There's a workaround there, by Baryon, which uses an Application variable,
and another workaround, by Naimish R. Dave, which lets you use Session variables.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
Are you using code-behind ?

If so, you need to use HttpContext.Current
.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"BenCoo" <te******@hotmail.comwrote in message
news:xm**********************@phobos.telenet-ops.be...
>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



Jun 3 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.