gpt4 book ai didi

c# - 获取 url 的主要部分,包括虚拟目录

转载 作者:可可西里 更新时间:2023-11-01 03:13:39 26 4
gpt4 key购买 nike

我正在使用 .net 4.0 c#。

我希望能够从当前的 http 请求中获取 url,包括任何虚拟目录。因此,例如(请求和寻求值(value)):

http://www.website.com/shop/test.aspx -> http://www.website.com/shop/

http://www.website.com/test.aspx -> http://www.website.com/

http://website.com/test.aspx -> http://website.com/

如何实现这一目标?

最佳答案

这是我用的

HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath;

关于c# - 获取 url 的主要部分,包括虚拟目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7999917/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com