ASP.NET Website Fundamentals

For those just starting to build web applications, we thought it useful to provide a high-level overview of how ASP.NET works to service user requests. Web development is a large and diverse topic. However, at its core, it is just Hypertext Markup Language (HTML) web pages pushed to browsers from web servers over Hypertext Transfer Protocol (HTTP) request/response. Understanding these fundamental concepts makes it easier to work with the greater complexities of web development (which we cover throughout this chapter). If you are familiar with writing web applications, we expect you to glance at Figure 17.1 and skip this section.

Image

FIGURE 17.1 A high-level overview of how ASP.NET uses the various .NET web components (such as the HTTP stack) and protocols to handle user requests routed to the server, process them, and return the results to the user’s browser.

Web development is about writing code to respond to a user request by first processing that request on the server, packaging a result back to the user, and allowing that result to execute on the client and ultimately render text, graphics, and behavior to the user. The code we write includes code for server-side processing of data and logic and client-side code to make the application dynamic and responsive to the user. Most of the other items we develop focus on making things look nice using HTML markup and Cascading Style Sheets (CSS). The following outlines how a web request is processed and results are rendered through the numbered items shown in Figure 17.1.

1. A compute device such as a PC, phone, tablet, or game console presents a web client application to the user. This could be a web browser or a native client application that speaks HTTP. The user then triggers a request to your web application. This request is defined by a unique uniform resource locator (URL).

2. The request is sent from the compute device network adapter using HTTP (Hypertext Transfer Protocol), typically through a local network/router, and then on to the user’s Internet service provider (ISP). The URL is looked up against a DNS (domain name server) in order to find a unique IP (internet protocol) address that maps to the domain name. The ISP then forwards the HTTP request on to your web server based on the IP address.

3. A web server receives the request (typically via a network at the hosting provider). The server is typically running a web server host application, such as Microsoft Internet Information Server (IIS). This application sits waiting for HTTP requests and is ready to route them to the right web application that will process them and prepare a response to the web server.

The request typically goes through an HTTP pipeline processer. This pipeline will validate the request and authorize user credentials (if any). The request is then routed to your code.

As you will see shortly, in an ASP.NET MVC application, the request is routed to a controller class library you write. The controller processes the request. This processing typically includes reaching out to a database server to get requested data, selecting a view for the HTML markup, executing any data to view binding, applying any other server-side code to build the response, and then returning the results to the server to be sent to the requesting client. These results include the view (as HTML) to be rendered, JavaScript to be run on the client, and images to be sent back to the client.

4. The web server bundles the response for a return trip to the user’s compute device (browser or native client application).

5. The response is routed back through the user’s ISP to the compute device. This routing is also done through the IP address.

6. The response is received by the user’s network and routed to the compute device’s network adapter. Ultimately, the response is sent to the HTTP handler (typically a web browser but could be a native client application) that made the request.

7. The HTTP handler (typically a web browser) on the compute device receives the results, processes them, and renders the visual representation of the markup to the user. Processing includes interpreting styles, loading images, executing JavaScript code, and more. Of course, the client application then stands ready to process any additional client-side JavaScript based on user action (and to generate the corresponding next request).

This fundamental understanding of web requests, processing, and response is meant to provide a high-level overview to orient web developers as they start working with ASP.NET 5. There are, of course, many additional complexities that make this work, such as caching, routers, load balancers, and the like. We hope to provide a general overview for developers. The sections (and other web chapters) that follow illustrate how ASP.NET 5 leverages these concepts to enable developers to build great things.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset