I want to make All Methods about Error handling in asp.net
some one device me at using global.asax
what is global.asax?
how can i use it ?
thanks , for help
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mageshwaran RPosted Nov 22, 2019, 10:42 AM
Andrew FensterPosted Jan 29, 2010, 12:58 AM
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
This method fires whenever there's an unhandled exception. So you can put code in this method to log the error, display an error message or do whatever else seems appropriate. That being said, you really should try to catch and handle errors long before they get to the Global.asax page. You can put try-catch blocks in individual methods. You can catch them at the page level. A very common technique is to write your own Page base class that catches errors and then make all your individual .aspx pages inherit from this base class. That's what I would recommend.
Here is an article that describes how to make your own custom base Page class and use it to handle errors. In most cases, this is the way to go.
http://www.codedigest.com/Articles/ASPNET/56_Using_Custom_BasePage_Class_in_ASPNet.aspx
Good luck to you.
Mahesh ChandPosted Jan 27, 2010, 1:55 PM
The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. The Global.asax file resides in the root directory of an ASP.NET-based application. At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplication base class. The Global.asax file itself is configured so that any direct URL request for it is automatically rejected; external users cannot download or view the code written within it.
The ASP.NET Global.asax file can coexist with the ASP Global.asax file. You can create a Global.asax file either in a WYSIWYG designer, in Notepad, or as a compiled class that you deploy in your application's \Bin directory as an assembly. However, in the latter case, you still need a Global.asax file that refers to the assembly.
The Global.asax file is optional. If you do not define the file, the ASP.NET page framework assumes that you have not defined any application or session event handlers.
Read here more about this
Here is an article on how to use Global.asax:
http://asp.dotnetheaven.com/aspnet/doc/applications/globalasax.aspx