
RewritePath | 305
HttpContext
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
tion file. While GetAppConfig returns an object, you must cast the returned
object to the NameValueCollection-derived type defined in the configuration
section to actually access the information.
Sub Page_Load( )
Dim i As Integer
Dim nv As NameValueCollection
nv = CType(Context.GetConfig("appSettings"), _
NameValueCollection)
For i = 0 To nv.Count - 1
Response.Write(nv.GetKey(i) & " = " & nv(i) & "<br/>")
Next
End Sub
Notes
Generally, you will not use GetConfig to get the appSettings section from the
configuration file. It is much easier and safer to use ConfigurationSettings.AppSet-
tings to get these values. This method, however, can be used to get information
from custom configuration sections.
RewritePath
Context.RewritePath(ByVal newURL As String)
Assigns an internal rewrite path.
Parameter
newURL
A String containing a local path to redirect the user silently.
Example
The example below shows how to change the path in a way that is completely
transparent to the user. The URL shown in the address bar remains the original
URL, and the redirection to the new page does not require a round trip to and
from the server. RewritePath is almost always called from global.asax rather than
an actual page. That is what this example shows.
Sub Application_BeginRequest(ByVal ...