Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I've understood the question.</p> <p><strong>Assumption</strong></p> <p>The full path is a path with in the current application or a child application. It is not a path limited to the parent nor a path into a sibling application. The desired path is relative to the current applications path.</p> <p><strong>Scenario 1</strong></p> <p>A path such as</p> <p>"/someApp/someFolder/someSubFolder/file.ext"</p> <p>should resolve it to:-</p> <p>"~/someFolder/someSubFolder/file.ext"</p> <p>(although the ~/ notation isn't something ASP classic understands).</p> <p><strong>Scenario 2</strong></p> <p>"/someApp/someSubApp/SomeSubFolder/file.ext"</p> <p>you still want:-</p> <p>"~/someFolder/someSubFolder/file.ext"</p> <p><strong>Scenario 3</strong></p> <p>The app is the root application of the site:-</p> <p>"/someFolder/someSubFolder/file.ext"</p> <p>would still become</p> <p>"~/someFolder/someSubFolder.file.ext"</p> <p><strong>Solution</strong></p> <p>The key to solving this is:-</p> <pre><code>Dim sAppMetaPath : sAppMetaPath = Request.ServerVariables("APPL_MD_PATH") </code></pre> <p>For the above set of scenarios this will result in something like:-</p> <ol> <li>"/LM/W3SVC/33230916/Root/someApp"</li> <li>"/LM/W3SVC/33230916/Root/someApp/someSubApp"</li> <li>"/LM/W3SVC/33230916/Root"</li> </ol> <p>Also</p> <pre><code>Dim sInstanceMetaPath: sInstanceMetaPath = Request.ServerVariables("INSTANCE_META_PATH") </code></pre> <p>will in all the scenarios return</p> <p>"/LM/W3SVC/33230916"</p> <p>With some mathematical reduction we can arrive at the function:-</p> <pre><code>Function ToAppRelative(virtualPath) Dim sAppMetaPath : sAppMetaPath = Request.ServerVariables("APPL_MD_PATH") Dim sInstanceMetaPath: sInstanceMetaPath = Request.ServerVariables("INSTANCE_META_PATH") ToAppRelative = "~/" &amp; Mid(virtualPath, Len(sAppMetaPath) - Len(sInstanceMetaPath) - 3) End Function </code></pre>
 

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