Export (0) Print
Expand All

HttpContext::RewritePath Method (String, String, String)

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

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public:
void RewritePath(
	String^ filePath, 
	String^ pathInfo, 
	String^ queryString
)

Parameters

filePath
Type: System::String

The internal rewrite path.

pathInfo
Type: System::String

Additional path information for a resource. For more information, see PathInfo.

queryString
Type: System::String

The request query string.

ExceptionCondition
ArgumentNullException

The path parameter is not in the current application's root directory.

HttpException

The filePath parameter is not in the current application's root directory.

The RewritePath 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.

For a code example, including an example of this method overload, see the RewritePath(String) method overload.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft