title: getting base url of web site's root (absolute/relative url)
body: <p>I want to completely understand how to use relative and absolute url address in static and dynamic files.</p>
  
  <pre><code>~  : 
  /  :
  .. : in a relative URL indicates the parent directory
   . : refers to the current directory
   / : always replaces the entire pathname of the base URL
  // : always replaces everything from the hostname onwards
  </code></pre>
  
  <p>This example is easy when you are working without virtual directory. But i am working on virtual directory.</p>
  
  <pre><code>Relative URI          Absolute URI
  about.html            http://WebReference.com/html/about.html
  tutorial1/            http://WebReference.com/html/tutorial1/
  tutorial1/2.html      http://WebReference.com/html/tutorial1/2.html
  /                     http://WebReference.com/
  //www.internet.com/   http://www.internet.com/
  /experts/             http://WebReference.com/experts/
  ../                   http://WebReference.com/
  ../experts/           http://WebReference.com/experts/
  ../../../             http://WebReference.com/
  ./                    http://WebReference.com/html/
  ./about.html          http://WebReference.com/html/about.html
  </code></pre>
  
  <p>I want to simulate a site below, like my project which is working on virtual directory.</p>
  
  <p>These are my aspx and ascx folder</p>
  
  <pre><code>http://hostAddress:port/virtualDirectory/MainSite/ASPX/default.aspx
  http://hostAddress:port/virtualDirectory/MainSite/ASCX/UserCtrl/login.ascx
  
  http://hostAddress:port/virtualDirectory/AdminSite/ASPX/ASCX/default.aspx
  </code></pre>
  
  <p>These are my JS Files(which will be use both with the aspx and ascx files):</p>
  
  <pre><code>http://hostAddress:port/virtualDirectory/MainSite/JavascriptFolder/jsFile.js
  http://hostAddress:port/virtualDirectory/AdminSite/JavascriptFolder/jsFile.js
  </code></pre>
  
  <p>this is my static web page address(I want to show some pictures and run inside some js functions):</p>
  
  <pre><code>http://hostAddress:port/virtualDirectory/HTMLFiles/page.html
  </code></pre>
  
  <p>this is my image folder</p>
  
  <pre><code>http://hostAddress:port/virtualDirectory/Images/PNG/arrow.png
  http://hostAddress:port/virtualDirectory/Images/GIF/arrow.png
  </code></pre>
  
  <p>if i want to write and image file's link in my ASPX file i should write </p>
  
  <pre><code>aspxImgCtrl.ImageUrl = Server.MapPath("~")+"/Images/GIF/arrow.png";
  </code></pre>
  
  <p>But if i want to write the path hard coded or from javascript file, what kind of url address it should be?</p>