Click here to Skip to main content
15,112,662 members
Articles / Web Development / IIS
Technical Blog
Posted 16 Apr 2012


13 bookmarked

ASP.NET Underground Tour (Part 1)

Rate me:
Please Sign up or sign in to vote.
4.83/5 (5 votes)
16 Apr 2012CPOL4 min read
To fully understand how to use ASP.NET, it is necessary to know the basic operation of the web (for example as occurs a request from browser to server, what are the technologies used, how a web server processes the request, etc.)

To fully understand how to use ASP.NET, it is necessary to know the basic operation of the web (for example, as occurs a request from browser to server, what are the technologies used, how a web server processes the request, etc.).

Understanding why a web page is not interpreted correctly in a browser, because a request is not performed as expected, or generate the appropriate HTML code from a custom control, are questions that do not depend only on knowledge of ASP.NET (or any other technology), but also from the knowledge of how a web application works.

HTTP Request and Response

The HTTP protocol (HyperText Transfer Protocol) was created as a mechanism for transferring hypertext documents defined as HyperText. The hypertext documents are related to each other by keywords clickable or hypertext links (hyperlinks).

Currently, however, a hypertext has become more complex, and the links are no longer just text, but can also be images; hypertext documents have become multimedia documents as well as the Protocol has been updated, also to compensate for inefficiencies of the first version, including the lack of security mechanisms.

It works, however, is always the same: an answer in response to a request (client / server); the client (browser) makes a request for a resource by opening a connection to the server (web server) which responds by sending the resource and the connection is closed.

A HTTP request is by commands established by the Protocol, including GET, POST, HEAD. Here’s an example:

We recall a page from the browser: http://localhost:80/Hello.html
Here is the HTTP request the browser sends to the server “localhost”:

GET /Hello.html HTTP/1.1
Host: localhost:80
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive

What interests us most is the first line (which specifies, by the GET command, the resource request, the protocol / version used) and the second line (which specifies the server to which the request is made). Everything else is superfluous for our purpose.

The server receives the request and processes it: in this case, the server will look for the resource indicated in the request and send the Response to the client. Here’s how the Response is made:

HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Wed, 06 Jul 2011 15:53:21 GMT
Accept-Ranges: bytes
Etag: "9259e2d4f43bcc1:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Sat, 15 Oct 2011 16:28:52 GMT
Content-Length: 130
        <h1> Hello World </h1>

The browser receives the response and shows the resource. In this case, it is a simple HTML page, then the browser will render the HTML code to make it visible. Operation is very basic, so needless to say any more.

Who Responds to this Request?

The server.
Well, now we need to explain …
In ancient times, there were … … CGI applications.
No, maybe I left too far!

We must speak of the present, and especially of the Microsoft platform. The solution is a service (daemon process) that listens on port 80 (default) and processes the requests. We are talking about IIS (Internet Information Services).

How does IIS to respond at the requests? Configuration is done by a mapping between file extensions and IIS extensions, which are typically external DLL calls ISAPI DLLs (Internet Services Application Programming Interface).

When a request comes to the server, it examines the file extension, the request can be handled directly by IIS (such as a JPG or HTML or any other static file is read and sent directly to the Response), or addressed to a particular extension ISAPI. This is the .aspx file case.

ISAPI mapping

ISAPI mapping

Requests on .aspx file are processed by aspnet_isapi.dll extension so that, in turn, send again the execution from the ASP.NET engine of the framework to the ASP.NET’s HTTP pipeline. Like the configuration of IIS, the ASP.NET engine map HTTP requests with specific handlers. These operators are just “pieces of code” that are concerned with generating the HTML code to be sent back in response.

The configuration of these mechanisms can be found in the web.config in the folder of the framework in use:
Below is shown the default configuration for the handler:

    <add path="*.svc" verb="*" 
    System.ServiceModel, Version=, Culture=neutral, 
    PublicKeyToken=b77a5c561934e089" validate="false"/>
    <add path="trace.axd" verb="*" 
    type="System.Web.Handlers.TraceHandler" validate="True"/>
    <add path="WebResource.axd" verb="GET" 
    type="System.Web.Handlers.AssemblyResourceLoader" validate="True"/>
    <add path="*.axd" verb="*" 
    type="System.Web.HttpNotFoundHandler" validate="True"/>
    <add path="*.aspx" verb="*" 
    type="System.Web.UI.PageHandlerFactory" validate="True"/>
    <add path="*.ashx" verb="*" 
    type="System.Web.UI.SimpleHandlerFactory" validate="True"/>
    <add path="*.asmx" verb="*" 
    System.Web.Services, Version=, Culture=neutral, 
    PublicKeyToken=b03f5f7f11d50a3a" validate="False"/>

Pipeline ASP.NET

Pipeline ASP.NET

As you can see, for the .aspx page is called “PageHandlerFactory” that will search the compiled class and invoke the requested page. In the event that the compiled class did not exist, the framework compiles itself the page and its code.


Technorati: , , , , , , , , , , , ,

Related Articles


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
Italy Italy
No Biography provided

Comments and Discussions

SuggestionSome suggestions Pin
Jani Giannoudis15-Apr-12 21:57
MemberJani Giannoudis15-Apr-12 21:57 
GeneralRe: Some suggestions Pin
cpsglauco21-Jun-12 2:29
Membercpsglauco21-Jun-12 2:29 
QuestionImage Link Pin
Vivek Krishnamurthy15-Apr-12 19:53
MemberVivek Krishnamurthy15-Apr-12 19:53 
GeneralRe: Image Link Pin
cpsglauco21-Jun-12 2:29
Membercpsglauco21-Jun-12 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.