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. Mail on every exception

Mail on every exception

Scheduled Pinned Locked Moved ASP.NET
15 Posts 5 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.
  • R Rock Star

    How can I make my exception handler? So I dont have to call function in each catch block.

    Rock Star

    A Offline
    A Offline
    adkalavadia
    wrote on last edited by
    #6

    In Global.asax File, <script language="C#" runat="server"> void Application_Error(object sender, EventArgs e) { //get reference to the source of the exception chain Exception ex = Server.GetLastError().GetBaseException(); //Insert email notification code here...use ex } </script> In your code Catch(Exception ex) { throw ex; }

    !- F - R - I - E - N - D - S -!

    R 1 Reply Last reply
    0
    • R Rock Star

      Hi, I want to add a functionality in my application that whenever any exception comes an email should be send to a programmer mentioned in web.config file. One way to achieve this is create a function and calling in every catch block in the application. Is there any other alternative so I dont have to call the function in every catch block and an email will be sent as exception comes. Thanking all

      Rock Star

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #7

      Have a look at NLog[^]. I believe that will give you what you want.

      me, me, me

      R 1 Reply Last reply
      0
      • A adkalavadia

        In Global.asax File, <script language="C#" runat="server"> void Application_Error(object sender, EventArgs e) { //get reference to the source of the exception chain Exception ex = Server.GetLastError().GetBaseException(); //Insert email notification code here...use ex } </script> In your code Catch(Exception ex) { throw ex; }

        !- F - R - I - E - N - D - S -!

        R Offline
        R Offline
        Rock Star
        wrote on last edited by
        #8

        Thanks for your help I'll try this code. Is it possible to retrieve the page name in Application_Error event in global.asax file so developer will aware of in which page error is occurred.

        Rock Star

        A 1 Reply Last reply
        0
        • R R Giskard Reventlov

          Have a look at NLog[^]. I believe that will give you what you want.

          me, me, me

          R Offline
          R Offline
          Rock Star
          wrote on last edited by
          #9

          Nope I don't want any application for this task I want to write a code for it in my application Thanks for your help

          Rock Star

          1 Reply Last reply
          0
          • R Rock Star

            Thanks for your help I'll try this code. Is it possible to retrieve the page name in Application_Error event in global.asax file so developer will aware of in which page error is occurred.

            Rock Star

            A Offline
            A Offline
            adkalavadia
            wrote on last edited by
            #10

            u can use ex.Messege, ex.Source properties. see all properties. in Global.asax.

            !- F - R - I - E - N - D - S -!

            R 1 Reply Last reply
            0
            • A adkalavadia

              u can use ex.Messege, ex.Source properties. see all properties. in Global.asax.

              !- F - R - I - E - N - D - S -!

              R Offline
              R Offline
              Rock Star
              wrote on last edited by
              #11

              Thanks for your help. :thumbsup:

              Rock Star

              1 Reply Last reply
              0
              • R Rock Star

                Hi, I want to add a functionality in my application that whenever any exception comes an email should be send to a programmer mentioned in web.config file. One way to achieve this is create a function and calling in every catch block in the application. Is there any other alternative so I dont have to call the function in every catch block and an email will be sent as exception comes. Thanking all

                Rock Star

                I Offline
                I Offline
                i gr8
                wrote on last edited by
                #12

                You can audit you errors in catch block and use SQL mailing option to send mail

                R 1 Reply Last reply
                0
                • I i gr8

                  You can audit you errors in catch block and use SQL mailing option to send mail

                  R Offline
                  R Offline
                  Rock Star
                  wrote on last edited by
                  #13

                  Thanks but I am looking for sending mail on any kind of exception not only database connectivity exception. Thanks to adkalavadia I got what I wanted.

                  Rock Star

                  1 Reply Last reply
                  0
                  • R Rock Star

                    Hi, I want to add a functionality in my application that whenever any exception comes an email should be send to a programmer mentioned in web.config file. One way to achieve this is create a function and calling in every catch block in the application. Is there any other alternative so I dont have to call the function in every catch block and an email will be sent as exception comes. Thanking all

                    Rock Star

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

                    This is what you are looking for : http://www.4guysfromrolla.com/articles/091306-1.aspx[^]

                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                    My Latest Articles-->** Simplify Code Using NDepend
                    Basics of Bing Search API using .NET
                    Microsoft Bing MAP using Javascript

                    R 1 Reply Last reply
                    0
                    • A Abhishek Sur

                      This is what you are looking for : http://www.4guysfromrolla.com/articles/091306-1.aspx[^]

                      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                      My Latest Articles-->** Simplify Code Using NDepend
                      Basics of Bing Search API using .NET
                      Microsoft Bing MAP using Javascript

                      R Offline
                      R Offline
                      Rock Star
                      wrote on last edited by
                      #15

                      I just want to extend the functionality. Like these days we usually have more than one application in a single project solution. If I got error on any application within same solution how can we capture this bug, instead of writing same code in each application's global.asax file. Thanking You!

                      Rock Star

                      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