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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.