本文介绍了获取没有查询字符串的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在没有查询字符串的情况下获取当前URL的最佳方法是什么?请注意,我需要整个URL.来自Http-或其他任何内容! 在此先感谢
What is the best way to get the current URL with no query strings? Please note, I need the ENTIRE URL. From Http - or whatever!! Thanks in advance
推荐答案尝试以下代码:thumbsup: Try this code :thumbsup: currentUrl = Request.Url;
你好, 也许这就是您想要的(从http到/等) hello, Maybe this is what you looking for (from http to /, etc...) <br /> String myUrl = Request.Url.Scheme + Uri.SchemeDelimiter +Request.Url.Host;<br />
更多示例: stackoverflow/questions/21640/net-get-protocol-host-和端口 [ ^ ]
More example: stackoverflow/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
发布评论