I did not find a suitable one on the Internet. I wrote one on my own and tested it to meet various situations.
Code # Region generate the absolute path of the URL application (http: // localhost: 8080/website)
String abspath = system. Web. httpcontext. Current. Request. url. absolutepath;
Abspath = abspath. substring (system. Web. httpcontext. Current. Request. applicationpath. Length );
This. _ apppath = system. Web. httpcontext. Current. Request. url. absoluteuri. Replace (abspath ,"");
This. _ apppath. trimend ('/');
# Endregion
# Region generate the physical path of the application hard disk (D: \ wwwroot \ website)
This. _ physicalpath = system. Web. httpcontext. Current. Request. servervariables ["appl_physical_path"]. tostring (). trimend ('\\');
# Endregion
# Region generate the absolute path of the URL application skin (http: // localhost: 8080/website/app_themes/green)
System. Web. configuration. pagessection _ PS = (system. Web. configuration. pagessection) system. configuration. configurationmanager. getsection ("system. Web/pages ");
This. _ themename = _ PS. theme;
This. _ fullthemepath = string. Format ("{0}/app_themes/{1}", this. _ apppath, _ PS. Theme). trimend ('/');
# Endregion