HttpContext.Current.Request.ApplicationPath
I had to blog this here, because I have the need for it every once in a while, but not frequent enough to remember it... :)
Examples:
A site hosted without a virtual directory: mysite.com/
Returns: "/"
A site hosted from a virtual directory: mysite.com/myVirtualDir
Returns: "/myVirtualDir"
See the MSDN Documentation for more details and code examples.
See the "ASP.NET Web Site Paths" article for more ways to discover paths.
No comments:
Post a Comment