IIS7 Returns Empty Response for Static Content (CSS/JS/Images) While ASP.NET Pages Work


8 views

After deploying an ASP.NET MVC application on Windows 7 Home Premium with IIS7, I encountered a peculiar scenario: dynamic ASP.NET pages rendered correctly while all static content (CSS, JavaScript, images) returned blank responses (HTTP 200 with empty body). No 404 or 500 errors appeared in the browser's dev tools.

First, let's verify the basic permissions:

icacls "C:\inetpub\wwwroot\myapp" /grant "IUSR:(RX)"
icacls "C:\inetpub\wwwroot\myapp" /grant "NETWORKSERVICE:(M)"

But permission wasn't the root cause. The issue stemmed from IIS7's static content handler configuration.

In IIS Manager, navigate to:

  1. Select your site → Handler Mappings
  2. Check if "StaticFile" handler exists

The crucial discovery was that the StaticFile handler might be disabled or misconfigured. Here's how to fix it:

%windir%\system32\inetsrv\appcmd set config /section:handlers /+[name='StaticFile',path='*',verb='GET,HEAD',modules='StaticFileModule',resourceType='Either',requireAccess='Read']

Add this to your web.config if you prefer configuration files:

<system.webServer>
    <handlers>
        <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="Either" requireAccess="Read" />
    </handlers>
</system.webServer>

After making these changes:

  • Restart IIS (iisreset)
  • Clear browser cache (Ctrl+F5)
  • Check F12 Network tab for response headers

If the issue persists, enable failed request tracing:

%windir%\system32\inetsrv\appcmd set config /section:sites /siteDefaults.traceFailedRequestsLogging.enabled:"true" /commit:apphost

Then create a tracing rule for *.css, *.js, and *.png files to capture detailed diagnostics.

In my case, the solution involved both enabling the StaticFile handler and ensuring the MIME types were properly configured:

%windir%\system32\inetsrv\appcmd set config /section:staticContent /+[fileExtension='.css',mimeType='text/css']
%windir%\system32\inetsrv\appcmd set config /section:staticContent /+[fileExtension='.js',mimeType='application/javascript']

This combination finally resolved the blank response issue completely.


When deploying an ASP.NET MVC application on Windows 7 with IIS7, you might encounter this peculiar behavior:

http://example.com/              → Works (dynamic ASP.NET content)
http://example.com/style.css     → Blank response (no 404/500)
http://example.com/logo.png      → Blank response

Before diving deep, verify these basics:

1. Static Content feature is installed:
   - Open "Turn Windows features on/off"
   - Internet Information Services → World Wide Web Services → Common HTTP Features
   - Ensure "Static Content" is checked

2. Request filtering isn't blocking file extensions:
   - In IIS Manager, select your site
   - Double-click "Request Filtering"
   - Check the "File Name Extensions" tab
   - Ensure .css, .js, .png etc. aren't blocked

While you've set permissions for IUSR and NetworkService, try this comprehensive approach:

icacls "C:\YourSitePath" /grant "IUSR:(RX)" /T
icacls "C:\YourSitePath" /grant "IUSR:(M)" /T
icacls "C:\YourSitePath" /grant "NETWORK SERVICE:(RX)" /T
icacls "C:\YourSitePath" /grant "NETWORK SERVICE:(M)" /T

In IIS7, static files are handled by the StaticFile handler. Verify its configuration:

<configuration>
  <system.webServer>
    <handlers>
      <add name="StaticFile" path="*" verb="*" 
           modules="StaticFileModule" 
           resourceType="Either" 
           requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>

Use these commands to gather more information:

# Check failed request tracing
appcmd list trace /text:* 

# Enable detailed logging
appcmd set config -section:system.webServer/httpLogging 
                  /dontLog:false /commit:apphost

Since you're using Home Premium, check this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components
Verify "StaticContent" = 1 (enabled)

If time is critical, attempt these solutions in order:

1. Reset IIS:
   iisreset /restart

2. Re-register ASP.NET:
   aspnet_regiis -i

3. Reinstall Static Content:
   dism /online /enable-feature /featurename:IIS-StaticContent

4. Create a new test.html file - if this works, compare permissions

As a last resort before reinstallation:

1. Export your site configuration:
   appcmd list app /text:* > config.txt

2. Backup your content

3. Uninstall/reinstall IIS:
   dism /online /disable-feature /featurename:IIS-WebServerRole
   [reboot]
   dism /online /enable-feature /featurename:IIS-WebServerRole