
Application | 293
HttpContext
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
The other somewhat unusual (although much more useful) method in HttpCon-
text is RewritePath. The MSDN documentation on this method is, shall we say,
sparse. The real use for this method is to silently redirect the user to a different
URL.
In this chapter, as in others in the book, we’ll use the following code listing as the
basis for most examples in the chapter. Unless otherwise noted, each example will
consist of the Page_Load event handler for just that particular example. Any
output messages or return values displayed will be shown as the Text property of
the ASP.NET Label control named Message or displayed by calling Response.
Write.
<%@ Page Language="vb" %>
<html>
<head>
<script runat="server">
Sub Page_Load( )
'Example code will go here
End Sub
</script>
</head>
<body>
<asp:label id="Message" runat="server"/>
</body>
</html>
Some examples will show Application handlers within global.asax rather than the
Page_Load method of a page.
Properties Reference
Application
HttpApplicationState = Context.Application
Returns the current Application state object.
Parameter
HttpApplicationState
An HttpApplicationState object that will receive the value of the property.
Example
The example sets an application value using the Application instance exposed by
the
Page