获取当前访问的部分虚拟路径(HttpContext.Current.Request.Url.GetLeftPart)

HttpContext.Current.Request.Url.GetLeftPart 的应用:

//发送按钮

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default3.aspx?id=10&name=aa">HyperLink</asp:HyperLink>

//接收页面

string baseUrl = "Path:" + Request.Url.GetLeftPart(UriPartial.Path) + "<br>|" + "Authority:" + Request.Url.GetLeftPart(UriPartial.Authority) + "<br>|" + "Query:" + Request.Url.GetLeftPart(UriPartial.Query) + "<br>|" + "Scheme:" + Request.Url.GetLeftPart(UriPartial.Scheme);

Response.Write(baseUrl);

//显示结果

Path:http://localhost:1061/WebSite1/Default3.aspx
|Authority:http://localhost:1061
|Query:http://localhost:1061/WebSite1/Default3.aspx?id=10&name=aa
|Scheme:http://

------------------------------- Jack -------------------------------------------

Request.ApplicationPath:"/DocumentSystem"

Server.MapPath("/documentsystem"):"D:\\COFCO\\VSProjects\\DocumentSystem"


命名空间:System.Web.HttpContext.Current.Request.Url


AbsolutePath   "/documentsystem/pages/DocHistory.aspx"

AbsoluteUri   "http://localhost/documentsystem/pages/DocHistory.aspx?id=ee603b98-8636-476b-983b-4c74e6e0db18"

Authority   "localhost"

DnsSafeHost   "localhost"

Host    "localhost"

HostNameType   Dns

HostType   IPv6HostType | IPv4HostType

IsAbsoluteUri   true bool

IsDefaultPort   true bool

IsDosPath   false bool

IsFile false   bool

IsImplicitFile   false bool

IsLoopback   true bool

IsUnc false   bool

IsUncOrDosPath   false bool

IsUncPath   false bool

OriginalString   "http://localhost/documentsystem/pages/DocHistory.aspx?id=ee603b98-8636-476b-983b-4c74e6e0db18" string

PathAndQuery   "/documentsystem/pages/DocHistory.aspx?id=ee603b98-8636-476b-983b-4c74e6e0db18" string

Port    80

PrivateAbsolutePath "/documentsystem/pages/DocHistory.aspx"

Query    "?id=ee603b98-8636-476b-983b-4c74e6e0db18"

Scheme    "http"


------------------------------- Jack -------------------------------------------

posted @ 2010-08-12 11:39  睿德泽林  阅读(3998)  评论(0编辑  收藏  举报