How can I handle my error class whenever any exception is raised.
-
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
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 }
-
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 }
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
-
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
In your web.config file add the following.
-
In your web.config file add the following.
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