Mail on every exception
-
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
-
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
Make class in App_Code Name "ErrorLog.cs". Make Public Fn WriteError(string ErrorMsg) Put your Email Send code here. call this method in every catch block. i.e.: catch(Exception ex) { this.WriteError(ex.Messege); }
!- F - R - I - E - N - D - S -!
-
Make class in App_Code Name "ErrorLog.cs". Make Public Fn WriteError(string ErrorMsg) Put your Email Send code here. call this method in every catch block. i.e.: catch(Exception ex) { this.WriteError(ex.Messege); }
!- F - R - I - E - N - D - S -!
-
I thought over it. But there are many catch blocks in the application. Is there any other solutions except writing it in every catch block.
Rock Star
you can make your own exception handler for handling exception. but i think class file is a better solution for your problem. :omg:
!- F - R - I - E - N - D - S -!
-
you can make your own exception handler for handling exception. but i think class file is a better solution for your problem. :omg:
!- F - R - I - E - N - D - S -!
-
How can I make my exception handler? So I dont have to call function in each catch block.
Rock Star
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 -!
-
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
-
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 -!
-
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
u can use ex.Messege, ex.Source properties. see all properties. in Global.asax.
!- F - R - I - E - N - D - S -!
-
u can use ex.Messege, ex.Source properties. see all properties. in Global.asax.
!- F - R - I - E - N - D - S -!
-
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
-
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
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 -
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 JavascriptI 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