You are on page 1of 22

ASP.

NET

Understanding Web Communications

ASP.NET
Like all client-server applications, web applications have two distinct components:
Client Also known as the front-end interface, the web browser presents the user interface, accepts user input, and sends data to the server for processing. Server Also known as the back end, the web server responds to requests from clients for specific pages. It responds with an HTML page that includes instructions for how to generate the user interface.

ASP.NET
The web browser (the client) and the web server communicate by using Hypertext Transfer Protocol (HTTP), a text-based network protocol assigned to TCP port 80. If the server has a certificate, the client and server can use HTTP Secure (HTTPS) to authenticate the server and encrypt communications. HTTPS is assigned to TCP port 443.

ASP.NET
Communications typically follow these steps: 1. A user enters an address, such as http://www.microsoft.com/ into the web browser.

2. The web browser connects by using HTTP and sends a GET request, such as GET/(to retrieve the root page), to the web server.
3. The web server processes the requested page. This action might cause the server to return static HTML or image files, or it might execute ASP.NET code that performs workflow tasks or connects to a database.

ASP.NET
4. The web server uses HTTP to send a response back to the web browser. If the request was processed successfully, the web server returns the HTTP status code 200, along with an HTML document. If the server cannot find the page, it returns the code 404. If the user requests an outdated or relocated page, the server returns thecode 302 and the new URL so that the browser can access the correct page. This is known as redirection. Several other responses are possible as well, depending on the particular situation.

ASP.NET
5. The users web browser then processes the response by displaying the HTML page (if the code was 200), showing an error message (if the code was 404), or loading a differentpage (if the code was 302). Other server responses are similarly handled by the browser, depending upon the response.

This process is repeated each time the user clicks a button or link.

The Web Servers Role


The web server provides the content and the web browser displays it to the user.When a web server receives a request, some ofthe actions it takes are to: 1. Verify that the request is structured legitimately. Sometimes, malicious clients send malformed web requests to compromise web servers. Web servers must be ableto detect this and respond appropriatelyusually by ignoring the request. 2. Authenticate itself. If the server has a Secure Sockets Layer (SSL) certificate and the request was made with HTTPS, the web browser uses the certificate to authenticate the server. The web server will also encrypt all content before returning it to the web browser.

The Web Servers Role


3. Authenticate the user. If the content requires authorization, the web server verifies that the user has submitted credentials. If the user has not been authenticated, the web server redirects the user to an authentication form. 4. Authorize the user. After the Web server authenticates the user, the web server verifies that the user is allowed to access the requested content. 5. Determine how to handle a request. If the web browser requested static content or was simply determining whether cached content could still be used, the web server can directly respond. If the web browser requested an ASP.NET page, the web server must forward the request to ASP.NET.

The Web Servers Role


6. Handle errors. If a server cannot process the users request, it provides error information to the web browser.
7. Cache output. Web servers can cache output to improve the response time of subsequent requests. Web servers also provide caching information to web browsers, so browsers know how long to keep content cached. 8. Compress output. Before returning a page to a web browser, a web servercan compress the content to reduce the bandwidth required. 9. Log access. Web servers typically record usage information for security and performance-monitoring purposes.

The Web Browsers Role


1. Send requests to the web server. If the user enters http://www.microsoft.com, the web browser resolves the www.microsoft.com Domain Name System (DNS) address, uses HTTP to connect to the server, and requests a page. 2. Authenticate the server. If the server has an SSL certificate and the request was made with HTTPS, the web browser uses the certificate to authenticate the server and then decrypt future communications.
3. Process the response. If the server has provided HTML, the browser retrieves embedded objects, such as images, videos, or animations referenced in the HTML. If the server has provided an error, redirection, or other response, the browser responds appropriately.

The Web Browsers Role


4. Display HTML and embedded objects. Web browsers use HTML standards to determine how to display a webpage to the user. Because HTML can contain embedded objects,a web browser might have to display dozens of objects to render a single webpage.
5. Run client scripts. Client scripts, such as those written in JavaScript, enable interactive and responsive pages without reloading the page.

Understanding the Role of HTTP


HTTP is a text-based communication protocol that is used to request webpages from a web server and send responses back to a web browser.
When a webpage is requested, the browser sends a request to the web server. The request might look like the following. GET /default.aspx HTTP/1.1 Host: www.northwindtraders.com

Common HTTP/1.1 Methods


HTTP METHOD
GET

DESCRIPTION

Gets an object, such as a webpage, from the server. A GET request for a specific URL (Uniform Resource Locator) retrieves the resource.For example, GET /test.htm retrieves the test.htm resource (typically a static file, but it could be generated dynamically).

Common HTTP/1.1 Methods


HTTP METHOD POST DESCRIPTION Sends data to the web server for processing. This is typically what happens when users enter data on a form and submit that data as part of their request, but it has other meanings when used outside the bounds of HTML forms.

Common HTTP/1.1 Methods


HTTP METHOD HEAD DESCRIPTION Retrieves the meta information for an object without downloading the page itself. HEAD is typically used to verify that a resource hasnt changed since the browser cached it.

Common HTTP/1.1 Methods


HTTP METHOD PUT
10 12

DESCRIPTION Allows a client to directly create a resource at the indicated URL on the server. If the user has permission, the server takes the body of the request, createsColumn 1 the Column file specified in the URL, and 2 Column 3 copies the received data to the newly created file.

0 Row 1 Row 2 Row 3 Row 4

Status Code Groups


Status Code Groups S 1xx
2xx 3xx 4xx

DESCRIPTION
Informational: The request was received, and the server is continuing to process. Success: The action was successfully received, understood, and accepted. Redirect Command: The client must access a different resource instead. Client Error: The request has a syntax error or the server does not knowhow to fulfill the request. Server Error: The server failed to fulfill a request that appears to be valid.

5xx

What is ASP.NET
ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server.
ASP.NET is a Microsoft Technology

ASP stands for Active Server Pages


ASP.NET is a program that runs inside IIS

IIS (Internet Information Services) is Microsoft's Internet server

What is ASP.NET File


An ASP.NET file is just the same as an HTML file
An ASP.NET file can contain HTML, XML, and scripts Scripts in an ASP.NET file are executed on the server

An ASP.NET file has the file extension ".aspx"

How ASP.NET Works


When a browser requests an HTML file, the server returns the file
When a browser requests an ASP.NET file, IIS passes the request to the ASP.NET engine on the server

The ASP.NET engine reads the file, line by line, and executes the scripts in the file
Finally, the ASP.NET file is returned to the browser as plain HTML

ASP.NET Framework

CLR

You might also like