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
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 “
GET /Hello.html HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept-Encoding: gzip, deflate
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
Last-Modified: Wed, 06 Jul 2011 15:53:21 GMT
Date: Sat, 15 Oct 2011 16:28:52 GMT
<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?
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.
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=220.127.116.11, Culture=neutral,
<add path="trace.axd" verb="*"
<add path="WebResource.axd" verb="GET"
<add path="*.axd" verb="*"
<add path="*.aspx" verb="*"
<add path="*.ashx" verb="*"
<add path="*.asmx" verb="*"
System.Web.Services, Version=18.104.22.168, Culture=neutral,
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: ASP.NET, HTML, HTTP, HTTP Handlers, HTTP Request, HTTP Response, Hypertext Transfer Protocol, Internet Information Services, Internet Server Application Programming Interface, ISAPI, ISAPI DLLs, PageHandlerFactory, Pipeline HTTP