Server.MapPath

HostingEnvironment.MapPath()

Posted on

TL;DR: always use HostingEnvironment.MapPath()

http://stackoverflow.com/questions/3795986/using-server-mappath-inside-a-static-field-in-asp-net-mvc

Server.MapPath specifies the relative or virtual path to map to a physical directory.

Server.MapPath(“.”)1 returns the current physical directory of the file (e.g. aspx) being executed
Server.MapPath(“..”) returns the parent directory
Server.MapPath(“~”) returns the physical path to the root of the application
Server.MapPath(“/”) returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)

http://stackoverflow.com/questions/275781/server-mappath-server-mappath-server-mappath-server-mappath?lq=1

Advertisements