During. NET programming, it is often difficult to use relative paths because of directory structure problems, instead of absolute URLs of applications. But this will involve the application name and port. I probably wrote a method to get the URL path.
Absolute URL path
# Region generate the absolute path of the URL Application
String abspath = system. Web. httpcontext. Current. Request. url. absolutepath;
Abspath = abspath. substring (system. Web. httpcontext. Current. Request. applicationpath. Length );
String asburl = system. Web. httpcontext. Current. Request. url. absoluteuri;
This. _ apppath = asburl. substring (0, asburl. indexof (abspath ));
This. _ apppath. trimend ('/');
# Endregion
Hard Disk Physical path and skin path
# Region generate the physical path of the application Hard Disk
This. _ physicalpath = system. Web. httpcontext. Current. Request. servervariables ["appl_physical_path"]. tostring (). trimend ('\\');
# Endregion
# Region generate the absolute path of the skin of the URL Application
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