How can I get the relative virtual path from the physical path in asp.net? The reverse method is like below:
Server.MapPath(\"Virtual Path Here\"); >
Server.MapPath(\"Virtual Path Here\");
Request.ServerVariables["APPL_PHYSICAL_PATH"]
is fine, but not always. It is available only if there's a HTTP request.
On the other hand the call
HostingEnvironment.ApplicationPhysicalPath
is always available.