Question

So I have an ASP.NET MVC4 page working in IIS:

iis screenshot

Only issue is that the static content is not served... (css, js, ... files)

This is the check-list that I've already done:

  1. Enable the "Static" component in the "Enable/Disable Windows Features" dialog inside Control Panel, underneath the IIS tree node.
  2. Have a <add path="*.css" verb="GET" type="System.Web.StaticFileHandler" /> inside the <system.web><httpHandlers> tag of my web.config.
  3. Have a <add name="CSS" path="*.css" verb="GET" type="System.Web.StaticFileHandler" preCondition="foo"/> inside the <system.webServer><handlers> tag of my web.config (foo being 'integratedMode' or 'ManagedHandler').
  4. Adding the "Impersonate a Client AfterAuthentication" privilege to my user (http://support.microsoft.com/kb/821546).
  5. Also tried adding entries in IIS directly, in the dialog "Module mappings". In fact @lex-li is telling me that this is not needed so long as I see the "*" mapping, which is this one:

Static File mapping that is already there

And it still doesn't serve the f**g files (404). What else am I missing?

In the log file (C:\inetpub\logs\LogFiles\W3SVC2\u_ex140313.log) I can see:

2014-03-13 18:21:09 192.168.0.161 GET /Content/Site.css - 80 - 192.168.0.150 Mozilla/5.0+(X11;+Ubuntu;+Linux+x86_64;+rv:26.0)+Gecko/20100101+Firefox/26.0 404 0 0 15
Was it helpful?

Solution

Alright, it was a permissions problem!

First, for my ASP.NET site to work, I had to do this in the IIS administration app, some days ago:

  • Click on your website node.
  • In the right panel, click on the 'Basic Configuration...' link.
  • Click on the button "Connect as...".
  • Choose "Specific user", and chose one which has Administration privileges.

(I mention this, in case the above has some effects on the thing I had to do below.)

Now, to solve my issue, I had to change the permissions of my folder (where I had my website written in the disk: C:\Users\knocte\Documents\Visual Studio 2012\Projects\SolutionFoo\ProjectFoo).

  • Go to C:\Users\knocte\Documents\Visual Studio 2012\Projects\SolutionFoo
  • Right click on 'ProjectFoo' folder -> Properties -> Security.
  • Click the "Edit..." button.
  • Click the "Add..." button.
  • Write "IIS_IUSRS", click "Check names".
  • Click "Accept" many times.

Refresh the page in your browser, now static files should work.

(You might also find trouble with the Temporary ASP.NET Files system folder, in which case look here.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top