Search code examples
asp.net-mvc-3iis-7.5asp.net-mvc-routinghttp-status-code-404

MVC3 Site on IIS7.5 - how do I make static content available outside session?


I have a MVC3 site with static images served nicely from /Content/images to users of the site, but I get a 404 if I try to access them outside a session.

This is problem for icons and small branding assests used in Facebook dialogs, as they quite naturally 404 when the third party page references them.

I added the following into a web.config in the /Content folder, but no dice:

<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>
<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <handlers>
    <remove name="BlockViewHandler" />
  </handlers>
</system.webServer>

These are only small files and while I could get them onto a third party CDN, it makes versioning more complicated.

I am thinking that I may need to either configure IIS to bypass ASP.NET routing OR create a /assets folder and add in something like routes.IgnoreRoute("assets/{*pathInfo}"); in Global.asax.

Best plan?

Martyn


Solution

  • Have you considered putting these assets on a sub domain?

    In the past I've put images on a different domain: images.mydomain.com