获取当前访问的部分虚拟路径

获取当前访问的部分虚拟路径(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 -------------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值