我有一个这样的URL:
http://www.example.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye
我想从中得到http://www.example.com/mypage.aspx。
你能告诉我怎么买吗?
我有一个这样的URL:
http://www.example.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye
我想从中得到http://www.example.com/mypage.aspx。
你能告诉我怎么买吗?
当前回答
Request.RawUrl.Split(new[] {'?'})[0];
其他回答
Request.RawUrl.Split(new[] {'?'})[0];
Request.RawUrl.Split('?')[0]
仅为url名!!
好的答案也在这里找到了答案来源
Request.Url.GetLeftPart(UriPartial.Path)
string url = "http://www.example.com/mypage.aspx?myvalue1=hello&myvalue2=goodbye";
string path = url.split('?')[0];
这是我的解决方案:
Request.Url.AbsoluteUri.Replace(Request.Url.Query, String.Empty);