title: Determine an absolute url to a resource using vbscript/classic asp
body: <p>I've created a pseudo user control for a site written in classic asp.  The control is simply an asp page (with full HTML headers and body) that resides within an iframe in the parent page.  The point was to create an AJAX-like interface for uploading files asynchronously (the parent page contains a large form and I didn't want to have to upload the files and submit the rest of the form at the same time).<br>
  The problem is, I'm running into a lot of issues with relative urls being used in the iframe page/user control.  Depending on what page the iframe is a child of, the relative url base location seems to change according to the directory that particular page is in.</p>
  
  <p>Example:
  www.website.com/directory1/application1.asp</p>
  
  <pre><code>...
  &lt;form&gt;
      &lt;input&gt;
      ...
      &lt;iframe src="../controls/FileUpload.asp"/&gt;
      ...
  &lt;/form&gt;
  ...
  </code></pre>
  
  <p>www.website.com/directory1/directory2/application2.asp</p>
  
  <pre><code>...
  &lt;form&gt;
      &lt;input&gt;
      ...
      &lt;iframe src="../../controls/FileUpload.asp"/&gt;
      ...
  &lt;/form&gt;
  ...
  </code></pre>
  
  <p>www.website.com/controls/FileUpload.asp</p>
  
  <pre><code>...
  &lt;form method="post" enctype="multipart/form-data" action="FileUpload.asp"&gt;&lt;!--problem here--&gt;
      &lt;input type="file"&gt;
      &lt;input type="submit"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The iframe src paths work correctly (notice the one that's buried a directory deeper has an extra double dot).  But in the code for the FileUpload.asp page, relative URLs don't work consistently.  The URL I have in the action attribute for the form tag works if you simply load the page as-is, not in an iframe of another page.  You can change it to "../controls/FileUpload.asp" and it will work on the first application page, but you have to add another "../" for it to work on the second application page.<br>
  I was wondering if maybe there's a way with vbscript to find the absolute URL to a certain file. I do use an include file into which I could hard-code this, but I'd rather not if that's possible. Any other ideas?</p>