Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > global.asax : Application_Error and Session don't work

Reply
Thread Tools

global.asax : Application_Error and Session don't work

 
 
BenCoo
Guest
Posts: n/a
 
      06-03-2007
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


 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      06-03-2007
"BenCoo" <(E-Mail Removed)> wrote in message
newsmB8i.212239$(E-Mail Removed)-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

 
Reply With Quote
 
 
 
 
BenCoo
Guest
Posts: n/a
 
      06-03-2007
Thanks, but didn't find a solution while the aspx-page where this error is
generated is in a subdirectory


"Mark Rae" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> "BenCoo" <(E-Mail Removed)> wrote in message
> newsmB8i.212239$(E-Mail Removed)-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



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-03-2007
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" <(E-Mail Removed)> wrote in message
newsmB8i.212239$(E-Mail Removed)-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
>
>



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-03-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> newsmB8i.212239$(E-Mail Removed)-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
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.Redirect from Application_Error - session changes lost Jon Paugh ASP .Net 1 11-30-2004 07:34 PM
Losing Session state in Application_Error DalePres ASP .Net 0 04-28-2004 12:46 AM
Session doesn't work in Application_Error in Global.aspx Mike Malter ASP .Net 3 03-29-2004 04:43 AM
Error handling in application_error, use session variables? Michael ASP .Net 1 12-29-2003 03:21 PM
Application_Error, Session, and custom error page Greg Burns ASP .Net 1 10-24-2003 04:32 PM



Advertisments