title: Ignoring Javascript, CSS and image files routing in ASP.net
body: <p>I've turned Stack Overflow up and down, but, unfortunately, none of the answers helped me. </p>
  
  <p>I have a web app that works perfectly on my local PC using IIS provided by the Visual Studio, but when I deploy this app to the server only the CSS is displayed properly.</p>
  
  <p>Folder structure for files is as follows:</p>
  
  <ul>
  <li>Root (this folder is named <strong>Knowledge Management</strong> on the server)
  <ul>
  <li><strong>CSS</strong></li>
  <li><strong>JS</strong></li>
  <li><strong>Media</strong></li>
  <li><strong>Uploads</strong>
  <ul>
  <li>Documents</li>
  <li>Images</li>
  <li>Users</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>My code, at least for Master page head section looks like this:</p>
  
  <pre><code>&lt;head runat="server"&gt;
      &lt;link href="CSS/Style.css" rel="stylesheet" /&gt;
      &lt;script src="/JS/jQuery203Min.js"&gt;&lt;/script&gt;
      &lt;script src="/JS/jQueryUI1103Min.js"&gt;&lt;/script&gt;
      &lt;asp:ContentPlaceHolder ID="head" runat="server"&gt;
      &lt;/asp:ContentPlaceHolder&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>However, browser generates it like this:</p>
  
  <pre><code>&lt;head&gt;
      &lt;link href="../../CSS/Style.css" rel="stylesheet" /&gt;
      &lt;script src="JS/jQuery203Min.js"&gt;&lt;/script&gt;
      &lt;script src="JS/jQueryUI1103Min.js"&gt;&lt;/script&gt;    
      &lt;script src="/JS/HomeArticles.js"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  </code></pre>
  
  <p>The problem is that besides CSS neither none of the files in JS folder and none of the files in Media or Uploads folders and subfolder doesn't generate properly.</p>
  
  <p>The thing is if I add "slash" in front of the image src attribute the image gets location <code>http://localhost/Media/Discussion.png</code> and if I don't add "slash" then the image location is <code>http://localhost/Uploads/Users/HrvojeFadiga.jpg</code> when it should be <code>http://localhost/Knowledge%20Management/Uploads/Users/HrvojeFadiga.jpg</code></p>
  
  <p>Here is a sample of code with images:</p>
  
  <pre><code>&lt;div class="profileInfoWrapper"&gt;
      &lt;img src="/Uploads/Users/&lt;%=article.User.PhotoLocation %&gt;" /&gt;
      &lt;span class="postInfo"&gt;
          &lt;img src="/Media/Rating.png" /&gt;&lt;%= GetArticleRating(article.idArticle) %&gt;
      &lt;/span&gt;
      &lt;span class="postInfo"&gt;
          &lt;img src="/Media/Visitors.png" /&gt;&lt;%= GetArticleViews(article.idArticle) %&gt;
      &lt;/span&gt;
      &lt;span class="postInfo"&gt;
          &lt;img src="/Media/Comments.png" /&gt;&lt;%= GetArticleComments(article.idArticle) %&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>FYI, Global.asax doesn't contain any rules for ignoring file routes except for .axd files which is added by default.</p>