.NET Framework Class Library
HttpRequest..::.PathInfo Property

Gets additional path information for a resource with a URL extension.

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

Visual Basic (Declaration)
Public ReadOnly Property PathInfo As String
Visual Basic (Usage)
Dim instance As HttpRequest
Dim value As String

value = instance.PathInfo
C#
public string PathInfo { get; }
Visual C++
public:
property String^ PathInfo {
    String^ get ();
}
JScript
public function get PathInfo () : String

Property Value

Type: System..::.String
Additional path information for a resource.
Remarks

For the URL Http://www.contoso.com/virdir/page.html/tail, the PathInfo value is /tail.

Examples

The following code example determines whether the PathInfo property contains an empty string. If it does, the Write method writes a string indicating this to a file. If it does not, the HtmlEncode method HTML-encodes the value of the PathInfo property and the WriteLine method writes the encoded value to the file. This code example is part of a larger example provided for the HttpRequest class.

Visual Basic
' Write the PathInfo property value
' or a string if it is empty.
If Request.PathInfo = String.Empty Then
    sw.WriteLine("The PathInfo property contains no information.")
Else
    sw.WriteLine(Server.HtmlEncode(Request.PathInfo))
End If
C#
// Write the PathInfo property value
// or a string if it is empty.
if (Request.PathInfo == String.Empty)
{
    sw.WriteLine("The PathInfo property contains no information.");
}
else
{
    sw.WriteLine(Server.HtmlEncode(Request.PathInfo));
}
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
See Also

Reference

Tags :


Community Content

Chris Strolia-Davis
Make sure to uncheck "Check that file exists" for extensions you want to get pathinfo for in IIS

Make sure to uncheck "Check that file exists" for extensions you want to get pathinfo for in IIS

If you use Request.PathInfo to get the path information for a file, it may not access the page you are using to process the pathinfo if you have not already set IIS so that it does not check to see that the file already exists.

If you are using IIS 5 (Standard for most XP machines),
Go to IIS, open the properties for the web site.
In the directories tab, click the configuration button.
Locate the extension of the file type that is processing the pathinfo (ex. .aspx, or .ashx) and click Edit.
Make sure that the Checkbox next to "Check that file exists" is unchecked.

In IIS 6, it is similar.
Open IIS and open the properties for the web site
In the Home Directories Tab, click the configuration button
Locate the extension of the file type that s processing the pathinfo (ex. .aspx, or .ashx) and click Edit.
Make sure that the Checkbox next to "Verify that the file exists" is unchecked.

I am not certain if IIS 7 has this issue or not, or what steps might be necessary if it does.

Tags :

Page view tracker