Friday, December 26, 2014

Exception

Types of Exception

There are the following 2 types of exceptions:
  1. System Exception.
  2. Application Exception.
System Exception

An exception raised implicitly from some predefined condition is a “System Exception”. For example DivideByZeroException, FormatException, OverFlowException and NullReference Exception.

If you want to learn about system exceptions then read my article:

Finally Block

Application Exception

An exception that is raised explicitly by the programmer in the application on its own condition is an “Application Exception”.

It can also referred to as a “User Defined Exception”.

Now let's we learn how to develop our own User Defined Exception.

Use the following procedure to develop a User Defined Exception.

Step 1: Inherit a class from the Exception class.

For example : Exception

Step 2: Override the string message from the exception class.

For example:
Public override string Message
{
    get
   {
        Return “Display the error Message when Exception Occur”
   }
} 
Step 3: In the other class, if an exception occurs that throws an exception for the creation of an object of your own exception class then do something.

For example:

Throws new

Tuesday, December 2, 2014

Creation of ASP.NET Environment

Step 1: The user sends a request to IIS. IIS first checks which ISAPI extension can serve this request. Depending on file extension the request is processed. For instance, if the page is an ‘.ASPX page’, then it will be passed to ‘aspnet_isapi.dll’ for processing. 


Step 2: If this is the first request to the website, then a class called as ‘ApplicationManager’ creates an application domain where the website can run. As we all know, the application domain creates isolation between two web applications hosted on the same IIS. So in case there is an issue in one app domain, it does not affect the other app domain.

Step 3: The newly created application domain creates hosting environment, i.e. the ‘HttpRuntime’ object. Once the hosting environment is created, the necessary core ASP.NET objects like ‘HttpContext’ , ‘HttpRequest’ and ‘HttpResponse’ objects are created.

Step 4: Once all the core ASP.NET objects are created, ‘HttpApplication’ object is created to serve the request. In case you have a ‘global.asax’ file in your system, then the object of the ‘global.asax’ file will be created. Please note global.asax file inherits from ‘HttpApplication’ class.
Note: The first time an ASP.NET page is attached to an application, a new instance of ‘HttpApplication’ is created. Said and done to maximize performance, HttpApplication instances might be reused for multiple requests.

Step 5: The HttpApplication object is then assigned to the core ASP.NET objects to process the page.

Step 6: HttpApplication then starts processing the request by HTTP module events, handlers and page events. It fires the MHPM event for request processing.

Followers

Link