Name
RewritePath
Synopsis
Context.RewritePath(ByVal newURL As String)
Assign s an internal rewrite path.
Parameters
-
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 sender As Object, _
ByVal e As EventArgs)
' No matter the URL, redirect to this URL...
Context.RewritePath("/aspnetian/ShowGetConfig.aspx")
End SubNotes
This method seems to be redundant when compared with methods like Server.Transfer, which allow the developer to change the page being displayed. In fact, RewritePath serves a very unique purpose.
Perhaps you have seen or registered at Web sites that give registered users a unique URL. For instance, you might be given a URL like this:
http://www.SomeDomain.com/YourName/default.aspx
Implementing such a system that gives a virtual directory to each user is not practical unless you have very few registered users. Using RewritePath, the developer can essentially remove a level of directory hierarchy. This removal occurs without a redirect that would require a round trip to the server, and without changing the URL as it appears in the browser. Some information ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access