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

15,700

Solution 1

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 authentication enter image description here

Solution 2

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
Share:
15,700
tsimbalar
Author by

tsimbalar

I am a passionate software engineer, specialized in object-oriented and web development. I enjoy working with new technologies to deliver great applications. I love learning new skills and constantly strive for improving my work. To stay up to date and improve my craft, I spend a lot of time reading (technical or nontechnical books, blogs, articles …), listening to podcasts and contributing to open source projects. I also enjoy applying and sharing what I learnt through those channels. I believe I deliver the best when working through the full development lifecycle, from idea to deployment, collaborating with customers and all the team members to create great solutions, and as such, I am a huge proponent of the agile methodologies and practices. I am used to working in multi-cultural teams, and I have been part of multiple projects in different countries (France, Belgium, Switzerland, Spain, Canada, India, Luxembourg) and different domains (public organizations, logistics, retail, banking, bio-testing). My strengths Very good knowledge of web-technologies: server-side, client-side & HTTP Fond of object-oriented programming and interested in other paradigms Fast-learner and enthusiast-teacher Curious, pro-active & perfectionist …: always seeking improvement … but pragmatic: practicality beats purity Agile practices fanatic: deliver early, TDD, Continuous Integration/Delivery Used to communicating in several languages Sensitive to Design and User-Experience

Updated on June 18, 2022

Comments

  • tsimbalar
    tsimbalar almost 2 years

    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 !