Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does ~/ not work inside script references?
    text
    copied!<p>I am using jQuery for my ASP.NET project. I just realized, that it does only work, if the navigation depth is not as deep. For example</p> <ul> <li><code>http://localhost/myapp/index/</code> works</li> <li><code>http://localhost/myapp/index/sites/sub/</code> does not work</li> </ul> <p>The error I encountered was caused by jQuery. Firebug told me, that</p> <blockquote> <p><code>$</code> is not defined.</p> </blockquote> <p>After some research, I changed my meta definitions like this:</p> <pre class="lang-asp.net prettyprint-override"><code>&lt;link rel="Stylesheet" type="text/css" href="~/Css/style.css" /&gt; &lt;script src="~/Scripts/jquery-1.7.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/jquery.uniform.min.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>Still, it did not work. After I took a look into the server response, the <code>href</code> of the CSS link got replaced correctly:</p> <pre class="lang-asp.net prettyprint-override"><code>&lt;link rel="Stylesheet" type="text/css" href="../../Css/style.css" /&gt; </code></pre> <p>However, for my script ressources the relative path hasn't been replaced:</p> <pre class="lang-asp.net prettyprint-override"><code>&lt;script src="~/Scripts/jquery-1.7.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/jquery.uniform.min.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>I expected something like <code>../../Scripts/jquery-1.7.2.min.js</code>.</p> <p>Is this wanted behaviour? How should I setup application root references for script resources, correctly? Would writing <code>/Scripts/jquery-1.7.2.min.js</code> work when I am hosting my website as web application in IIS?</p>
 

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