mrj*_*_05 2 .net asp.net url path relative-path
我怎样才能获得域名,例如:
网址:http:// localhost:11093/SiteA/Admin/Default.aspx
然后,我想只得到:http:// localhost:11093/SiteA /
我在用:
Path.GetFileName(Request.Url.Host)
Run Code Online (Sandbox Code Playgroud)
但只能得到:localhost,并尝试:
Path.GetFileName(Request.Url.PathAndQuery)
Run Code Online (Sandbox Code Playgroud)
但得到整个地址.非常感谢你.
试试这个:
var HostAndPath = Request.Url.AbsoluteUri.Replace(Request.Uri.AbsolutePath, "")
Run Code Online (Sandbox Code Playgroud)