Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Seguros Catatumbo - 13 Sep 2007 14:06 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.