System.Web.HttpContext.RewritePath Method

Rewrites the URL by using the given path, path information, and query string information.

Syntax

public void RewritePath (string filePath, string pathInfo, string queryString)

Parameters

filePath
The internal rewrite path.
pathInfo
Additional path information for a resource. For more information, see HttpRequest.PathInfo.
queryString
The request query string.

Remarks

The HttpContext.RewritePath(string, string, string) method redirects a request for a resource to another resource without changing the URL.

The filePath parameter does not include the pathInfo parameter content. For the URL http://www.microsoft.com/virdir/page.html/tail, the filePath parameter is http://www.microsoft.com/virdir/page.html, and the pathInfo parameter is tail.

URL rewriting is useful when you want to restructure the pages in your Web application, and you want to make sure that people who have bookmarked old URLs can still use them after you have moved pages. URL rewriting enables you to transparently forward requests to the new page location.

If you want to enable a site to use URLs that are more user-friendly and are optimized for search engines, a more robust alternative is to use ASP.NET routing. For more information, see ASP.NET Routing.

Requirements

Namespace: System.Web
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0