asp.net 取得URL信息

AbsolutePath = "/ReportManage/ReportWindow.aspx"

AbsoluteUri = "http://localhost:18725/ReportManage/ReportWindow.aspx?action=PickGoodsInfo&keyid=4ffeb15b-c269-451a-95a0-1eb22cbefd18"

Authority = "localhost:18725"

Host = "localhost"

LocalPath = "/ReportManage/ReportWindow.aspx"


OriginalString = "http://localhost:18725/ReportManage/ReportWindow.aspx?action=PickGoodsInfo&keyid=4ffeb15b-c269-451a-95a0-1eb22cbefd18"


PathAndQuery = "/ReportManage/ReportWindow.aspx?action=PickGoodsInfo&keyid=4ffeb15b-c269-451a-95a0-1eb22cbefd18"


Query = "?action=PickGoodsInfo&keyid=4ffeb15b-c269-451a-95a0-1eb22cbefd18"


Segments = {string[3]}
[0] = "/"
[1] = "ReportManage/"
[2] = "ReportWindow.aspx"

 顺便给出以下地址的方法,给到多少级,自己看着用Length-n

 http://localhost:18725/ReportManage/

            string[] webnet=new string[Context.Request.Url.Segments.Length-1];

            Array.Copy (Context.Request.Url.Segments,webnet ,Context.Request.Url.Segments.Length-1);

Context.Request.Url.Authority + string.Join("", webnet) 

网上90%的,不知道是不是版本的问题,都是错误的,寒一个!!

原文地址:https://www.cnblogs.com/szyicol/p/1808762.html