Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom Error Page

Custom Error Page

Scheduled Pinned Locked Moved ASP.NET
helpsysadmindebuggingtutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Niungareamit
    wrote on last edited by
    #1

    Hi, I am working on how to create an custom error page for application error. I have tried the following code I have one button on a page which generate an error on onClick event e.g. protected void ExceptionButton_Click(object sender, EventArgs e) { throw new Exception("Hello World!"); }I have Added a global.asax file and on Application_Error event i have written the following code: void Application_Error(object sender, EventArgs e) { Message.LastException = Server.GetLastError().GetBaseException(); string message = "Error Caught in Application_Error event\n" + "Error in: " + Request.Url.ToString() + "\nError Message:" +Message.LastException.Message.ToString() + "\nStack Trace:" + Message.LastException.StackTrace.ToString(); } But when i run the application and click on a button I got the error at line " throw new Exception("Hello World!");" My required otput is that instead of showing this error it should display the message that i have given in Application_Error event in global.asax file... but I am not getting an output. Can anybody help me???????

    A 1 Reply Last reply
    0
    • N Niungareamit

      Hi, I am working on how to create an custom error page for application error. I have tried the following code I have one button on a page which generate an error on onClick event e.g. protected void ExceptionButton_Click(object sender, EventArgs e) { throw new Exception("Hello World!"); }I have Added a global.asax file and on Application_Error event i have written the following code: void Application_Error(object sender, EventArgs e) { Message.LastException = Server.GetLastError().GetBaseException(); string message = "Error Caught in Application_Error event\n" + "Error in: " + Request.Url.ToString() + "\nError Message:" +Message.LastException.Message.ToString() + "\nStack Trace:" + Message.LastException.StackTrace.ToString(); } But when i run the application and click on a button I got the error at line " throw new Exception("Hello World!");" My required otput is that instead of showing this error it should display the message that i have given in Application_Error event in global.asax file... but I am not getting an output. Can anybody help me???????

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      are you in debug mode. during debugging, it always shows first chance exceptions. ...

      Abhishek Sur My Latest Articles Basics on LINQ and Lambda Expressions
      Create .NET Templates

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups