title: How to deal with IIS sub applications using MVC routing?
body: <p>I have an MVC application that has been moved to a sub folder in the wwwroot, and this sub folder has been made an application via IIS. So whereas before the url to my login page would look like this:</p>
  
  <p><strong>www.mydomain.com/login</strong></p>
  
  <p>It now looks like this:</p>
  
  <p><strong>www.mydomain.com/application/login</strong></p>
  
  <p>The application works fine, it doesn't seem to have affected the routing or any of the links in my application. However, it is causing problems where I am referencing image src's like so:</p>
  
  <pre><code>&lt;img src="/content/images/myimage.png"/&gt;
  </code></pre>
  
  <p>As it is attempting to retrieve the image from the url <strong>www.mydomain.com/content/images/myimage.png</strong> which obviously returns a 404.</p>
  
  <p>In my global.asax file I am only using the default route, which I have attempted to modify to account for the subfolder as part of the url:</p>
  
  <pre><code>routes.MapRoute("Default",
                  "application/{controller}/{action}/{id}",
                  new { controller = "dashboard", action = "index", id = UrlParameter.Optional });
  </code></pre>
  
  <p>However, now when I attempt to go to the root url <strong>www.mydomain.com/application</strong> I just get a directory listing! And if I try to go directly to controller i.e  <strong>www.mydomain.com/application/dashboard</strong> I get a 404!</p>
  
  <p>Anyone got any idea how to deal with this situation via MVC routing?</p>