title: How to Properly Reference a JavaScript File in an ASP.NET Project?
body: <p>I have some pages that reference javascript files.</p>
  
  <p>The application exists locally in a Virtual Directory, i.e. <a href="http://localhost/MyVirtualDirectory/MyPage.aspx" rel="noreferrer">http://localhost/MyVirtualDirectory/MyPage.aspx</a></p>
  
  <p>so locally I reference the files as follows:</p>
  
  <pre><code>&lt;script src="/MyVirtualDirectory/Scripts/MyScript.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The production setup is different though. The application exists as its own web site in production, so I don't need to include the reference to the virtual directory. The problem with this is that I need to modify every file that contains a javascript reference so it looks like the following:</p>
  
  <pre><code>&lt;script src="../Scripts/MyScript.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I've tried referencing the files this way in my local setup but it doesn't work.</p>
  
  <p>Am I going about this completely wrong? Can somebody tell me what I need to do?</p>
  
  <p>Thanks</p>