Custom error page does not work (Server.GetLastError() is null)

S

Seguros Catatumbo

Hello guys, i am trying to port my custom asp 3.0 error page to
asp.net.
I want to disable debugging in my asp.net projects but i want to show
the users a pretty page but that page should send me an email with the
details of the error.

On classic asp i just went to iis and mapped the 500 error code to
error.asp, which does this:

set objError = Server.getLastError()
numero = objError.AspCode
tipo = objError.Category
pagina = objError.File
descripcion = objError.Description
fuente = Server.HTMLEncode(objError.Source)
linea = ObjError.Line
iis = ObjError.ASPDescription

and i send all that info via email.

It is my understanding that i dont have to mess with IIS on asp.net. I
just set customErrors on web.config properly, and indeed i get the
pretty error page, but when i do this:

Exception ex = Server.GetLastError();

It always returns null. How can i make this work?

Also, on asp.net i dont seem to have the same info i get on classic
asp (code, category, file, descripcion, source, line...), how can i
get the same data?
 
S

Seguros Catatumbo

Exception ex = Server.GetLastError();

It always returns null. How can i make this work?

Ok, after a lot of searching, somehow it seems that i needed to add a
global.asax page and handle the error here:

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception ex = Server.GetLastError();
Server.Transfer("error500.aspx");
}
Also, on asp.net i dont seem to have the same info i get on classic
asp (code, category, file, descripcion, source, line...), how can i
get the same data?

I still can't seem to emulate the rest of the fields that i have
available on classic asp. Seems that asp.net dumps everything on the
exception itself.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top