Question:
asp.net error handeling question.?
2007-03-01 22:55:47 UTC
hi i wanted to know if anyone here has their own method of handeling errors on asp.net , were using c#. i setup the web.config file with these attributes
====================================





===========================================
now when i run the page i still get the error page that tells me to setup my web.config files error handling with the above code, i also tried setting it to on and the same thing happends.

also on other pages when i load it, i get errors like line 1: bla bla "=" something to do with an equal sign.

is there a way to trap these errros as much as possible and display a custom error page? instead of the ugly error page.
most of the errors i recieve are internal hard to understand errors.

thanks
Three answers:
Rex M
2007-03-01 23:05:00 UTC
The easiest way is to simply wrap each page logic in a try/catch:



Page_Load()

{

try

{

//all your normal code goes here

}

catch

{

//code here will run if an error occurred in the try block

}

}



If you are looking for something a little more robust and sophisticated, I recommend exploring the Exception Handling application block of the Enterprise Library - http://msdn.microsoft.com/practices/guidetype/AppBlocks/
?
2016-12-18 08:57:42 UTC
I observed a ecu the day earlier at present jogging down the line. i assume you think of there is an blunders there to boot. Isaac is the only one here who is conscious what he's speaking approximately. And specific, i complete a sentence with a preposition.
jimmyparija
2007-03-01 23:07:35 UTC
set that error mode="off"

and change in the global.aspx file to ur custom error file..


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...