Programming in almost language

This is the site where you may share your knowledge and experience to eachother..

  • Categories

  • LinkedIn

  • Tweet Me

  • My footsteps

ASP.NET 2.0 Architecture

Posted by muradabbas on November 13, 2008

ASP.NET 2.0 Architecture

Article 01:

In this article ASP.NET 2.0 Architecture is being discussed which will help us to understand the inner working rather the internals of the technology. This series of articles will help you to master in ASP.NET by implementing specific features that will address you to know what happens when a code is written, how web request is processed and many other things related to internal structure and how implementation of ASP.NET Version 2.0 takes place.

In this brief introductory article we will be discussing about two ideas at a very high level.

Firstly, we will introduce ideas which will be elaborated in the coming lines and make sure where these ideas fit into overall architecture of ASP.NET 2.0.

Secondly, we will look at a utility called ‘Reflector’ which allows to peak inside the compiled version of ASP.NET and discover what exactly ASP.NET 2.0 Version compiler does to the declarative and imperative code. Here are the series of articles will contain many conceptual ideas which will give you a strong background for giving exams like 70-528(MCTS for Web Based Client).

Let’s begin with a very high level of ASP.NET Version 2.0 architecture.

The challenge of ASP.NET is that you can leverage your existing programming skills in building windows application that can run inside the context of a .NET Runtime known as WINFORM, Web UI is developed using a declarative code like HTML as well as the Event Driven Programming model which we are accustomed to use for Win Form like applications.

For example when creating a Win Form Application you might drop a control like  button on  the UI designer and then double click on that button for the access of the handler code in the default event(In this case the click event). Once the application is compiled the user of the application clicks a button and that accesses this button control and this particular action of case clicking is executed performing the instruction that has been written.

  • Example: Building a Win Form Application
  • Dropping a control on the UI Design
  • Double clicking to write code in the default even handler.
  • Clicking the button to execute code.
  • Etc.

How do you duplicate this experience with Web Based Development?

To match this model and aware environment this can be a bit tricky due to the unique nature of Web Application. For example, there was no concept of ‘State’ in a web application and HTTP and HTML were in the format of stages which couldn’t pass any idea regarding the technology which would create browser based applications. However 20 years later web based application development has practically become the fact for application development platform. The problem in this is that there exists a stress in the technology that was never resilient intended to be used. The way was intended to be inner link library document repository, there is no intrinsic need to manage state or in other words there was no need for the Web Server where the web client maintain the information about the user experience, each new request or action between the Web Server and the client online and dynamic web pages constructed from data contain within database became more main stream, application performance became a larger issue, tools for web developers became more effective, facilitating style of development all these considerations have shaped the  ASP.NET Version 2.0.

* Web is inherently stateless.

· Was originally intended to be a light weight document repository for the scientific community.

· No intrinsic need to manage state.

* As new demands were made, tools and technologies (Like ASP.NET) were created.

There are three essential parts ASP.NET 2.0,

The first is API or rather a set of classes allowing developer programmatically interact with information that sent in the page request make by the clients web browser as well as the data is formulated as the response to satisfy their request. There are different classes that  interacts with the information which are as follows: class which represents the page as a whole, class which represents the application as a whole, class which represents a single user session, class which represents a user itself, class representing the elements on a web page including  the HTML control and so on….

The second part of ASP.NET 2.0 is compiler that will convert both the imperative code and the declarative code written by the developer into a series of .NET assemblies that will serve as the end point for the client browser requests be an HTTP. These assemblies contain classes that implement special interface that can respond the request and are known as HTTP handlers.

And the third part of the ASP.NET 2.0 is a plug-in to Internet Information Services (IIS) is referred to as ‘ISAPI Extension’ that take HTTP requests and forwards them to appropriate HTTP handler, it also manages application and session wise services such as state and security, and we will examine each of these topics in details in coming articles.

· API- Classes programmers can use to interact with request and response data.

· Compiler- Turns code into .NET assemblies.

· ISAPI Extension – Plug-in to IIS to handle ASP.NET page request.

In this series of article

ASP.NET 2.0 – Request Pipeline processing

ASP.NET 2.0 – Page Compilation

ASP.NET 2.0 – Page Life Cycle

ASP.NET 2.0 – Application Life Cycle

ASP.NET 2.0 – Compilation Model

Anatomy of an ASP.NET 2.0 Web Site

Anatomy of an ASP.NET 2.0 Web Page

ASP.NET 2.0 – State Management

Now as I spoke, in the next few lines I want to focus on utility that are provide us a sneak peaks inside if ASP.NET compiler.

Lutz Roeder’s .NET Reflector Utility…….

· Allows us to see the intermediate Language compiler into a .NET Assembly.

· Allows us to see the IL translated into a language (we understand VB, C# etc.)

It not only allows us to see inside of a .NET assembly but also allows you to convert MSIL into IL language so that you can see it represented VB or C# code which is very neat and very enlightening. So you can find the reflector utility http://www.aisto.com/roeder/dotnet/.

Download the Reflector.exe, unzip it and click on the Reflector.exe.

After clicking on the reflector.exe you will find a new window then select the exact version of .NET Framework (which in case is Version 2.0……)

Then click on the OK button.

The various namespaces within the system and the classes can be seen and now we can implement this specific feature.

Now you can open any application you have been working on or just create a sample application.

Now if you want to find that temporary assemblies created by the sample application. First open the windows explorer and go to this path


C:\\windows\Microsoft.NET\Framework\V2.0.50727\TemporaryASP.NETFiles\<SampleProject>\Temporary Version (like 7a6e638).

These are the assemblies which are created when we ran the project, during testing.

Now an assembly is selected and is first drag it and then dropped on to the Reflector Window.

The new assembly at the reflector window is now at the bottom.

When you expand it you can see that.

For example expand the _ (underscore) tree and you will find many other things.

Select the _default class you will find many other things you can select any method or class (For example select Page_Load (Object, EventArgs): void) double click it will open an dis-assembler. And that allows us to see the C# code or we can switch this to VB.

You can click on any other method or even you can see the code which is written by yourself, and some of this can be auto generated code also.

Now let’s look at a method which we have created such as populatedata. If we were to compare this generated source code it will be very similar to that which you have written.

Now let’s look at the intermediate language (IL) which is not very human readable. So we will use this reflector to navigate through all assemblies that we have created to get clues and ideas about what’s going on behind the scene whenever we compile our applications with the ASP.NET compiler. It will help us to term in other things like ASP.NET control Tree like how it’s build up and then generate some web page, how events are fired an so on…

Very useful…………


-Murad Abbas (Sr. Associate Technology)
murad.abbas@gmail.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: