获取没有查询字符串的URL [英] Get url with no query strings
本文介绍了获取没有查询字符串的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在没有查询字符串的情况下获取当前URL的最佳方法是什么?请注意,我需要整个URL.来自Http-.com或其他任何内容!
在此先感谢
What is the best way to get the current URL with no query strings? Please note, I need the ENTIRE URL. From Http - .com or whatever!!
Thanks in advance
推荐答案
尝试以下代码:thumbsup:
Try this code :thumbsup:
currentUrl = Request.Url;
你好,
也许这就是您想要的(从http到.com/.net等)
hello,
Maybe this is what you looking for (from http to .com/.net, etc...)
<br />
String myUrl = Request.Url.Scheme + Uri.SchemeDelimiter +Request.Url.Host;<br />
更多示例:
http://stackoverflow.com/questions/21640/net-get-protocol-host-和端口 [ ^ ]
More example:
http://stackoverflow.com/questions/21640/net-get-protocol-host-and-port[^]
在下面使用此代码
hi
use this code below
string orginalUrl = HttpContext.Current.Request.Url.AbsoluteUri;
if (HttpContext.Current.Request.Url.Query.Length > 0)
orginalUrl = orginalUrl.Replace(HttpContext.Current.Request.Url.Query, string.Empty);
这篇关于获取没有查询字符串的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文