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?
Seguros Catatumbo - 13 Sep 2007 14:49 GMT
> 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.
Peter Bromberg [C# MVP] - 13 Sep 2007 18:52 GMT
Use Exception ex = Server.GetLastError().GetBaseException();
THAT is the exception.
http://support.microsoft.com/kb/306355
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
> Hello guys, i am trying to port my custom asp 3.0 error page to
> asp.net.
[quoted text clipped - 27 lines]
> asp (code, category, file, descripcion, source, line...), how can i
> get the same data?