如何从Request.Url.AbsolutePath
获取应用程序相对url?
VirtualPathUtility
似乎只适用于~/XXX
个URL?
如何从Request.Url.AbsolutePath
获取应用程序相对url?
VirtualPathUtility
似乎只适用于~/XXX
个URL?
我是这样解决的:
// create an absolute path for the application root
var appUrl = VirtualPathUtility.ToAbsolute("~/");
// remove the app path (exclude the last slash)
var relativeUrl = HttpContext.Current.Request.Url.AbsolutePath.Remove(0, appUrl.Length - 1);