Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Session doesn't work in Application_Error in Global.aspx

Reply
Thread Tools

Session doesn't work in Application_Error in Global.aspx

 
 
Mike Malter
Guest
Posts: n/a
 
      02-28-2004
I have a general error page that I configured in web.config as
<customErrors mode="On" defaultRedirect="CRDefaultError.aspx" />
This error page comes up whenever an error occurs outside of any try/catch blocks.

This page has a text box in it that I would like to fill with relevant information about the error. I am trying to put the
Server.GetLastError().ToString() in there. It did not work on the page, and I read somewhere that I should create a session
variable in the Application_Error event in Global.aspx. My problem is that if I try to create a session variable in
Application_Error, it throws another error!

So, is there anyway that I can simply grab the Server.GetLastError().ToString() and get to it in my custom error page?

Thanks.

Mike




 
Reply With Quote
 
 
 
 
Mike Malter
Guest
Posts: n/a
 
      02-29-2004
Marshal,

Thanks. I'll try this.

Mike

"Marshal Antony" <(E-Mail Removed)> wrote in message news:%23pgLX6n$(E-Mail Removed)...
> Hi Mike,
> Use your Server.GetLastError() in Application_Error event handler in
> Global.asax.cs. and store it in a Session variable there.
> protected void Application_Error(Object sender, EventArgs e)
>
> {
>
> Exception last_Error=Server.GetLastError();
>
> if(last_Error!=null)
>
> {
>
> Session["last_Error"]=last_Error.ToString();
>
> // You can redirect to your custom error page from here and can access the
> Session variable Session["last_Error"] from there.
>
> Response.Redirect("CRDefaultError.aspx");
>
> }
>
> Hope this helps.
>
> Regards,
>
> Marshal Antony
>
> .NET Developer
>
> http://www.dotnetmarshal.com
>
>
>
>
>
>
>
> "Mike Malter" <(E-Mail Removed)> wrote in message
> news:uG1w13c$(E-Mail Removed)...
> > I have a general error page that I configured in web.config as
> > <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" />
> > This error page comes up whenever an error occurs outside of any try/catch

> blocks.
> >
> > This page has a text box in it that I would like to fill with relevant

> information about the error. I am trying to put the
> > Server.GetLastError().ToString() in there. It did not work on the page,

> and I read somewhere that I should create a session
> > variable in the Application_Error event in Global.aspx. My problem is

> that if I try to create a session variable in
> > Application_Error, it throws another error!
> >
> > So, is there anyway that I can simply grab the

> Server.GetLastError().ToString() and get to it in my custom error page?
> >
> > Thanks.
> >
> > Mike
> >
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Mike Malter
Guest
Posts: n/a
 
      03-01-2004
Marshal,

The problem here is still the same, whenever I try to assign a value to a session variable in the Application_OnError event I get
another error.

Any thoughts?

Thanks.

Mike

"Marshal Antony" <(E-Mail Removed)> wrote in message news:%23pgLX6n$(E-Mail Removed)...
> Hi Mike,
> Use your Server.GetLastError() in Application_Error event handler in
> Global.asax.cs. and store it in a Session variable there.
> protected void Application_Error(Object sender, EventArgs e)
>
> {
>
> Exception last_Error=Server.GetLastError();
>
> if(last_Error!=null)
>
> {
>
> Session["last_Error"]=last_Error.ToString();
>
> // You can redirect to your custom error page from here and can access the
> Session variable Session["last_Error"] from there.
>
> Response.Redirect("CRDefaultError.aspx");
>
> }
>
> Hope this helps.
>
> Regards,
>
> Marshal Antony
>
> .NET Developer
>
> http://www.dotnetmarshal.com
>
>
>
>
>
>
>
> "Mike Malter" <(E-Mail Removed)> wrote in message
> news:uG1w13c$(E-Mail Removed)...
> > I have a general error page that I configured in web.config as
> > <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" />
> > This error page comes up whenever an error occurs outside of any try/catch

> blocks.
> >
> > This page has a text box in it that I would like to fill with relevant

> information about the error. I am trying to put the
> > Server.GetLastError().ToString() in there. It did not work on the page,

> and I read somewhere that I should create a session
> > variable in the Application_Error event in Global.aspx. My problem is

> that if I try to create a session variable in
> > Application_Error, it throws another error!
> >
> > So, is there anyway that I can simply grab the

> Server.GetLastError().ToString() and get to it in my custom error page?
> >
> > Thanks.
> >
> > Mike
> >
> >
> >
> >

>
>



 
Reply With Quote
 
Marshal Antony
Guest
Posts: n/a
 
      03-29-2004
Hi Mike,
Use your Server.GetLastError() in Application_Error event handler in
Global.asax.cs. and store it in a Session variable there.
protected void Application_Error(Object sender, EventArgs e)

{

Exception last_Error=Server.GetLastError();

if(last_Error!=null)

{

Session["last_Error"]=last_Error.ToString();

// You can redirect to your custom error page from here and can access the
Session variable Session["last_Error"] from there.

Response.Redirect("CRDefaultError.aspx");

}

Hope this helps.

Regards,

Marshal Antony

..NET Developer

http://www.dotnetmarshal.com







"Mike Malter" <(E-Mail Removed)> wrote in message
news:uG1w13c$(E-Mail Removed)...
> I have a general error page that I configured in web.config as
> <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" />
> This error page comes up whenever an error occurs outside of any try/catch

blocks.
>
> This page has a text box in it that I would like to fill with relevant

information about the error. I am trying to put the
> Server.GetLastError().ToString() in there. It did not work on the page,

and I read somewhere that I should create a session
> variable in the Application_Error event in Global.aspx. My problem is

that if I try to create a session variable in
> Application_Error, it throws another error!
>
> So, is there anyway that I can simply grab the

Server.GetLastError().ToString() and get to it in my custom error page?
>
> Thanks.
>
> Mike
>
>
>
>



 
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
global.asax : Application_Error and Session don't work BenCoo ASP .Net 4 06-03-2007 10:16 PM
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
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