得到URL的主要部分,包括虚拟目录 [英] get main part of url including virtual directory
本文介绍了得到URL的主要部分,包括虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我与.NET 4.0 C#的工作。
I am working with .net 4.0 c#.
我希望能够从当前的HTTP请求,包括任何虚拟目录得到的URL。因此,例如,(请求和追捧值):
I want to be able to get the url from the current http request, including any virtual directory. So for example (request and sought 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/
这怎么可能实现这一目标?
How is it possible to achieve this?
推荐答案
这是我使用
HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath;
这篇关于得到URL的主要部分,包括虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文