Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Server.MapPath</strong> specifies the relative or virtual path to map <strong>to a physical directory</strong>.</p> <ul> <li><code>Server.MapPath(".")</code><sup>1</sup> returns the current physical directory of the file (e.g. aspx) being executed</li> <li><code>Server.MapPath("..")</code> returns the parent directory</li> <li><code>Server.MapPath("~")</code> returns the physical path to the root of the application</li> <li><code>Server.MapPath("/")</code> returns the physical path to the root of the domain name (is not necessarily the same as the root of the application)</li> </ul> <p><em>An example:</em></p> <p>Let's say you pointed a web site application (<code>http://www.example.com/</code>) to</p> <pre><code>C:\Inetpub\wwwroot </code></pre> <p>and installed your shop application (sub web as virtual directory in IIS, marked as application) in </p> <pre><code>D:\WebApps\shop </code></pre> <p>For example, if you call <code>Server.MapPath()</code> in following request:</p> <pre><code>http://www.example.com/shop/products/GetProduct.aspx?id=2342 </code></pre> <p>then:</p> <ul> <li><code>Server.MapPath(".")</code><sup>1</sup> returns <code>D:\WebApps\shop\products</code></li> <li><code>Server.MapPath("..")</code> returns <code>D:\WebApps\shop</code></li> <li><code>Server.MapPath("~")</code> returns <code>D:\WebApps\shop</code></li> <li><code>Server.MapPath("/")</code> returns <code>C:\Inetpub\wwwroot</code></li> <li><code>Server.MapPath("/shop")</code> returns <code>D:\WebApps\shop</code></li> </ul> <p>If Path starts with either a forward slash (<code>/</code>) or backward slash (<code>\</code>), the <code>MapPath()</code> returns a path as if Path was a full, virtual path. </p> <p>If Path doesn't start with a slash, the <code>MapPath()</code> returns a path relative to the directory of the request being processed.</p> <p><em>Note: in C#, <code>@</code> is the verbatim literal string operator meaning that the string should be used "as is" and not be processed for escape sequences.</em></p> <p><em>Footnotes</em></p> <ol> <li><code>Server.MapPath(null)</code> and <code>Server.MapPath("")</code> will <a href="https://stackoverflow.com/a/17616488/1185053">produce this effect too</a>.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload