Request的几种路径属性
说明懒得写。直接代码~
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("<center><h1>Request的几种路径属性</h1></center><br />");
Response.Write("<font color=blue>服务器上 ASP.NET 应用程序的虚拟应用程序根路径</font>(<font color=green>ApplicationPath</font>):<font color=red>" + Request.ApplicationPath + "</font><br />");
Response.Write("<font color=blue>应用程序根的虚拟路径,并通过对应用程序根使用波形符表示法使该路径成为相对路径(<font color=green>AppRelativeCurrentExecutionFilePath</font>):</font><font color=red>" + Request.AppRelativeCurrentExecutionFilePath + "</font><br />");
Response.Write("<font color=blue>当前请求的虚拟路径</font>(<font color=green>CurrentExecutionFilePath</font>):<font color=red>" + Request.CurrentExecutionFilePath + "</font><br />");
Response.Write("<font color=blue>当前请求的虚拟路径</font>(<font color=green>FilePath</font>):<font color=red>" + Request.FilePath + "</font><br />");
Response.Write("<font color=blue>当前请求的虚拟路径</font>(<font color=green>Path</font>):<font color=red>" + Request.Path + "</font><br />");
Response.Write("<font color=blue>具有 URL 扩展名的资源的附加路径信息</font>(<font color=green>PathInfo</font>):<font color=red>" + Request.PathInfo + "</font><br />");
Response.Write("<font color=blue>当前正在执行的服务器应用程序的根目录的物理文件系统路径</font>(<font color=green>PhysicalApplicationPath</font>):<font color=red>" + Request.PhysicalApplicationPath + "</font><br />");
Response.Write("<font color=blue>与请求的 URL 相对应的物理文件系统路径</font>(<font color=green>PhysicalPath</font>):<font color=red>" + Request.PhysicalPath + "</font><br />");
Response.Write("<font color=blue>获取当前请求的原始 URL</font>(<font color=green>RawUrl</font>):<font color=red>" + Request.RawUrl + "</font><br />");
Response.Write("<font color=blue>有关当前请求的 URL 的信息</font>(<font color=green>Url</font>):<font color=red>" + Request.Url + "</font><br />");
Response.Write("<font color=blue>有关客户端上次请求的 URL 的信息,该请求链接到当前的 URL</font>(<font color=green>UrlReferrer</font>):<font color=red>" + Request.UrlReferrer + "</font><br />");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Post" /></div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("<center><h1>Request的几种路径属性</h1></center><br />");
Response.Write("<font color=blue>服务器上 ASP.NET 应用程序的虚拟应用程序根路径</font>(<font color=green>ApplicationPath</font>):<font color=red>" + Request.ApplicationPath + "</font><br />");
Response.Write("<font color=blue>应用程序根的虚拟路径,并通过对应用程序根使用波形符表示法使该路径成为相对路径(<font color=green>AppRelativeCurrentExecutionFilePath</font>):</font><font color=red>" + Request.AppRelativeCurrentExecutionFilePath + "</font><br />");
Response.Write("<font color=blue>当前请求的虚拟路径</font>(<font color=green>CurrentExecutionFilePath</font>):<font color=red>" + Request.CurrentExecutionFilePath + "</font><br />");
Response.Write("<font color=blue>当前请求的虚拟路径</font>(<font color=green>FilePath</font>):<font color=red>" + Request.FilePath + "</font><br />");
Response.Write("<font color=blue>当前请求的虚拟路径</font>(<font color=green>Path</font>):<font color=red>" + Request.Path + "</font><br />");
Response.Write("<font color=blue>具有 URL 扩展名的资源的附加路径信息</font>(<font color=green>PathInfo</font>):<font color=red>" + Request.PathInfo + "</font><br />");
Response.Write("<font color=blue>当前正在执行的服务器应用程序的根目录的物理文件系统路径</font>(<font color=green>PhysicalApplicationPath</font>):<font color=red>" + Request.PhysicalApplicationPath + "</font><br />");
Response.Write("<font color=blue>与请求的 URL 相对应的物理文件系统路径</font>(<font color=green>PhysicalPath</font>):<font color=red>" + Request.PhysicalPath + "</font><br />");
Response.Write("<font color=blue>获取当前请求的原始 URL</font>(<font color=green>RawUrl</font>):<font color=red>" + Request.RawUrl + "</font><br />");
Response.Write("<font color=blue>有关当前请求的 URL 的信息</font>(<font color=green>Url</font>):<font color=red>" + Request.Url + "</font><br />");
Response.Write("<font color=blue>有关客户端上次请求的 URL 的信息,该请求链接到当前的 URL</font>(<font color=green>UrlReferrer</font>):<font color=red>" + Request.UrlReferrer + "</font><br />");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Post" /></div>
</form>
</body>
</html>
运行结果: