Common ASP.Net Web Virtual and Relative Url helper classes

By | November 4, 2016

List of ASP.Net Web/MVC Virtual Paths,Relative and Absolute Paths Utility helper classes
Property Input Url Return Value
HttpRequest.ApplicationPath http://localhost/testapp/home.aspx /testapp
HttpRequest.CurrentExecutionFilePath http://localhost/testapp/home.aspx /testapp/home.aspx
HttpRequest.FilePath http://localhost/testapp/home.aspx /testapp/home.aspx
HttpRequest.AppRelativeCurrentExecutionFilePath http://localhost/testapp/home.aspx ~/testapp/home.aspx
HttpRequest.Path http://localhost/testapp/home.aspx /testapp/home.aspx/PathInfo
HttpRequest.PhysicalApplicationPath http://localhost/testapp/home.aspx C:inetpubwwwrootTestApp
HttpRequest.RawUrl http://localhost/testapp/home.aspx?user=1 /testapp/home.aspx?user=1
UrlHelper.Content ~/testapp/home.aspx c:inetpubwwwroottestapphome.aspx
Property Input Url Return Value
HttpContext.Current.Request.Url.Host http://localhost:8080/testapp/home.aspx?user=1&new=2 localhost
HttpContext.Current.Request.Url.Authority http://localhost:8080/testapp/home.aspx?user=1&new=2 localhost:8080
HttpContext.Current.Request.Url.AbsolutePath http://localhost:8080/testapp/home.aspx?user=1&new=2 /testapp/home.aspx
HttpContext.Current.Request.Url.AbsoluteUri http://localhost:8080/testapp/home.aspx?user=1&new=2 http://localhost:8080/testapp/home.aspx?user=1&new=2
HttpContext.Current.Request.Url.PathAndQuery http://localhost:8080/testapp/home.aspx?user=1&new=2 /testapp/home.aspx?user=1&new=2
HttpContext.Current.Request.RawUrl http://localhost:8080/testapp/home.aspx?user=1&new=2 /testapp/home.aspx?user=1&new=2
Property Input Url Return Value
VirtualPathUtility.GetFileName http://localhost/testapp/home.aspx home
VirtualPathUtility.GetExtension http://localhost/testapp/home.aspx aspx
VirtualPathUtility.GetDirectory http://localhost/testapp/home.aspx /testapp/
VirtualPathUtility.IsAbsolute http://localhost/testapp/home.aspx True
VirtualPathUtility.IsAppRelative http://localhost/testapp/home.aspx False
VirtualPathUtility.ToAppRelative http://localhost/testapp/home.aspx ~/home.aspx
VirtualPathUtility.ToAbsolute ~/home.aspx /testapp/home
VirtualPathUtility.AppendTrailingSlash http://localhost/testapp/home.aspx http://localhost/testapp/home.aspx/