获取没有查询字符串的URL

编程入门 行业动态 更新时间:2024-10-21 14:41:11
本文介绍了获取没有查询字符串的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

本文发布于:2023-11-17 12:06:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609949.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!