1
votes

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
1
At any level of IIS (server, site, app), you should be able to see the IIS static file module listed as the last item of Handler Mappings, where it monitors Path of * and the Handler is StatusFileModule,DefaultDocumentModule,DirectoryListingModule. I don't think you need another handler in this case. Meanwhile, when "it still doesn't serve", what is the status code logged in IIS log files?Lex Li
It gives a 404 when I try to access the files with the browser. Where are the IIS log files?knocte
404 is a large family, so you should start from support.microsoft.com/kb/943891Lex Li
interesting! how can I find out which 404 error it's returning?knocte
@LexLi: I've added the log line, does that mean a 404.15 error?knocte

1 Answers

0
votes

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.)