我可以使用以下代码获取浏览器的URL:
string url = HttpContext.Current.Request.Url.AbsoluteUri;
但是,如果我的URL如下所示:http://www.test.com/MyDirectory/AnotherDir/testpage.aspx
我如何获取其中的"MyDirectory"部分,有没有 .NET 中的实用程序可以做到这一点,或者我需要进行字符串操作?
如果我进行字符串操作并说在第一个 "/" 后面的任何内容,那么它不会返回 http: 后面的斜杠吗? 如果我的 url 是 www.test.com/MyDirectory/AnotherDir/testpage.aspx
,那么它会起作用。
有人能帮忙吗?
AbsolutePath
? - Miserable Variable