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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s