How to get the URL of the root directory
This article mainly explains "how to get the URL of the root directory". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to get the URL of the root directory".
The copy code is as follows:
Public static string GetRootURI ()
{
String AppPath = ""
HttpContext HttpCurrent = HttpContext.Current
HttpRequest Req
If (HttpCurrent! = null)
{
Req = HttpCurrent.Request
String UrlAuthority = Req.Url.GetLeftPart (UriPartial.Authority)
If (Req.ApplicationPath = = null | | Req.ApplicationPath = = "/")
/ / install it directly on the Web site
AppPath = UrlAuthority
Else
/ / install it in the virtual subdirectory
AppPath = UrlAuthority + Req.ApplicationPath
}
Return AppPath
}
Thank you for your reading, the above is the content of "how to get the URL of the root directory". After the study of this article, I believe you have a deeper understanding of how to get the URL of the root directory, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!