HttpRequest.FilePath 属性
定义
获取当前请求的虚拟路径。Gets the virtual path of the current request.
public:
property System::String ^ FilePath { System::String ^ get(); };
public string FilePath { get; }
member this.FilePath : string
Public ReadOnly Property FilePath As String
属性值
当前请求的虚拟路径。The virtual path of the current request.
示例
下面的代码示例使用 HtmlEncode 方法对属性的值进行 HTML 编码 FilePath ,并使用 WriteLine 方法将编码的值写入文件。The following code example uses the HtmlEncode method to HTML-encode the value of the FilePath property and the WriteLine method to write the encoded value to the file. 此代码示例是为类提供的更大示例的一部分 HttpRequest 。This code example is part of a larger example provided for the HttpRequest class.
// Write request information to the file with HTML encoding.
sw.WriteLine(Server.HtmlEncode(DateTime.Now.ToString()));
sw.WriteLine(Server.HtmlEncode(Request.CurrentExecutionFilePath));
sw.WriteLine(Server.HtmlEncode(Request.ApplicationPath));
sw.WriteLine(Server.HtmlEncode(Request.FilePath));
sw.WriteLine(Server.HtmlEncode(Request.Path));
' Write request information to the file with HTML encoding.
sw.WriteLine(Server.HtmlEncode(DateTime.Now.ToString()))
sw.WriteLine(Server.HtmlEncode(Request.CurrentExecutionFilePath))
sw.WriteLine(Server.HtmlEncode(Request.ApplicationPath))
sw.WriteLine(Server.HtmlEncode(Request.FilePath))
sw.WriteLine(Server.HtmlEncode(Request.Path))
注解
FilePath属性不包括 PathInfo 尾部。The FilePath property does not include the PathInfo trailer. 例如,对于 URL http://www.contoso.com/virdir/page.html/tail
, FilePath 值为/virdir/page.html。For example, for the URL http://www.contoso.com/virdir/page.html/tail
, the FilePath value is /virdir/page.html.