Most of the time asp.net developers faces some exceptions in their applications / websites which came in some exceptional and rare cases. To handle them, we will do something new by using global.asax
Also add a new class file under the App_Code folder. In my case, my file name is Myglobal.vb, inherit this class file to HttpApplication.
Now, open the file and select the page event Error in MyGlobal.vb class file and write your code to handle the exception whether you want to log the error or redirect to the customized error page or whatever do you want, it is upto you.
Now add a global.asax file into your project, make sure the Application_OnError event should be written in global.asax file.
Open the file and add a page directive into global.asax like this i.e.
<%@ Application Language="VB" Inherits="MyGlobal" %>
MyGlobal is the name of my class file which i added into App_Code folder earlier.
Test your code.
It's all about Knowledge blog is a Pakistan’s leading Blog offering new techniques, logic, ready made solutions and tools to developers, students, professionals or IT personnel in order to increase their productivity, skills, knowledge. Keep updated and sharpen with new controls, applications, gadgets and tool. This blog also offers free stuff like free e-books, free download able codes, videos, gadgets, controls, tools and consultation.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment