Working with Context

The complement to the application and page events is the context, which is provided by ASP.NET. The available contexts allow you to do the following:

  • Get information about the request received from the client.
  • Configure aspects of the response that will be returned.
  • Issue instructions to the ASP.NET server as the request is processed.

The ASP.NET contexts are request, response, and server. Let’s see how they can be put to use.

The Request Context

You can get details of the request made by the client through the Page.Request property, which returns an instance of the System.Web.HttpRequest class. To demonstrate this class, let’s make some changes to the Default.aspx web page in the example project, as shown in Listing 5-8 ...

Get Applied ASP.NET 4 in Context now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.