Get the App
SLTechnology News&Howtos  ›  Development  › 

How to get the URL of the root directory

Shulou Source: shulou.com Published: 2022-06-03 07:46:10 11月15日 Update

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!

Tags: Root directory learning code content subitems subdirectories that is ideas situations articles more knowledge knowledge points sites articles follow questions practice push research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Linux Shulou Tech Info Shulou Technology