现在的位置: 首页 > 综合 > 正文

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

2013年08月30日 ⁄ 综合 ⁄ 共 646字 ⁄ 字号 评论关闭

http://blog.csdn.net/jinru2560/article/details/870586

 

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://

抱歉!评论已关闭.