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. How can I handle my error class whenever any exception is raised.

How can I handle my error class whenever any exception is raised.

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-nethelp
5 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.
  • M Offline
    M Offline
    m rastgar
    wrote on last edited by
    #1

    I have an error class in my asp.net with c# project. It is responsible for handling errors. Could I handle it, when any exception raises, my class method raise? If yes, tell me how? Thanks Rastgar

    T 1 Reply Last reply
    0
    • M m rastgar

      I have an error class in my asp.net with c# project. It is responsible for handling errors. Could I handle it, when any exception raises, my class method raise? If yes, tell me how? Thanks Rastgar

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      Add a Global.asx file to your application. Put your code in the following method. void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs }

      GameFly free trial

      M 1 Reply Last reply
      0
      • T ToddHileHoffer

        Add a Global.asx file to your application. Put your code in the following method. void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs }

        GameFly free trial

        M Offline
        M Offline
        m rastgar
        wrote on last edited by
        #3

        I know application error event. But there is a problem with it. I should just redirect to another page in this event else, the page which error is raised, will be redirected to error page. But I’d like my old page is still shown. And I show the error in another page. I know that I should write in this event: Response.Write("window.open('errorpage.aspx')"); But the page that error raises from that will be still redirected to error page or ASP.Net default errorpage. What should I do to prevent from this redirection? Thanks Rastgar

        T 1 Reply Last reply
        0
        • M m rastgar

          I know application error event. But there is a problem with it. I should just redirect to another page in this event else, the page which error is raised, will be redirected to error page. But I’d like my old page is still shown. And I show the error in another page. I know that I should write in this event: Response.Write("window.open('errorpage.aspx')"); But the page that error raises from that will be still redirected to error page or ASP.Net default errorpage. What should I do to prevent from this redirection? Thanks Rastgar

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          In your web.config file add the following.

          M 1 Reply Last reply
          0
          • T ToddHileHoffer

            In your web.config file add the following.

            M Offline
            M Offline
            m rastgar
            wrote on last edited by
            #5

            As I mentioned, if I set this tag off, the asp.net shows the error in old page. But I want the old page still be shown. If you get confused, plz read my first and second message again to find out my question correctly. I should clear asp default error and show my old page. But how? Server.clearerro() method just clear the asp error but my old page never be recovered. thanks rastgar

            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