Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static images and CSS not showing (401) but bundled css and js do

We just deployed an ASP.NET MVC 4 webapp in production and are experimenting a strange behavior : the app works but images are not showing and part of the CSS is not loading.

When analyzing the HTTP requests, I can see that :

  • requests to images (*.png) fail with a 401 status code
  • requests to css files fail with a 401 status code
  • requests to bundled resources (*.js / *.css) are successful.

The application has worked properly in our Dev/Integration/Staging and Pre-Prod environment so I expect it to be some IIS configuration trick ....

We have already checked that :

  • only anonymous authentication is enabled in IIS
  • the IIS Pool user has Read access to the resources

I should add that some old HTTP modules are also configured (they take care of redirecting the user to some login page if he is not authenticated ...)

(I don't know whether this is relevant, but the app fails with HTTP status 401 when accessing its root Url (virtual directory) without the trailing slash ... i.e. https://{the domain}/{WebApp Name} fails but https://{the domain}/{WebApp Name}/ works fine)

Any clue about what might be going on ?

Thanks !

like image 793
tsimbalar Avatar asked Jan 09 '14 16:01

tsimbalar


2 Answers

Folder Authentication in IIS][1]

I was able to fix it by..

  1. Navigating to folder that has css files in IIS
  2. Double click "Authentication" icon on "Features View"
  3. Right click Anonymous Authentation as shown in the pic and select Edit
  4. Select "Application pool identity" option as shown in the pic
  5. Restart the website
like image 91
crazy coding Avatar answered Nov 06 '22 06:11

crazy coding


I could finally figure it out ...

  1. Anonymous authentication was enabled (and using default config implying that the user seen by the code is the user IUSR).
  2. The files for the web app were not stored locally where IIS is installed, but on some sort of network shared drive ....
  3. In that place, IUSR had no read permissions, and could therefore not read the static resources.

I had to change the default "pass-though authentication", specifying that local execution is not done as the "authenticated users" (IUSR in that case).

In the WebApp Basic Settings in IIS, do not use "pass-throuh" authentication, use "Connect as"

do not use pass-through authenticationenter image description here

like image 39
tsimbalar Avatar answered Nov 06 '22 05:11

tsimbalar