The problem may be that IIS is not serving Static Content, which you can set up here:
Source: http://adilmughal.com/blog/2011/11/iis-7-not-loading-css-and-image/
Windows 10:
I had the same problem, an unauthenticated page would not load the CSS, JS and Images when I installed my web application in ASP.Net 4.5 in IIS 8.5 on Windows Server 2012 R2.
Yet, nothing seemed to solved the problem. Then finally I tried setting the identity of the anonymous user to the App Pool Identity and it started working.
I banged my head for a few hours and hope that this response will save the agony for my fellow developers.
I would really like to know why this is working. Any thoughts?
I had a similar error, my console looked like this:
My problem was that I was running my site in a sub folder since the company was using one top domain and no sub domains. Like this:
host.com/app1
host.com/app2
My code looked like this for including scripts which worked fine on localhost but not in app1 or app2:
<link rel="stylesheet" type="text/css" href="/Content/css/font-awesome.min.css" />
Added a tilde sign ~
to src and then everything worked:
<link rel="stylesheet" type="text/css" href="~/Content/css/font-awesome.min.css" />
Explanation of ~
vs /
:
/
- Site root~/
- Root directory of the application/
will return the root of the site (http://host.com/
),
~/
will return the root of the application (http://host.com/app1/
).
Try removing the staticContent section from your web.config.
<system.webServer>
<staticContent>
...
</staticContent>
</system.webServer>
This might not answer your question but I've been banging my head with the same symptoms with a new IIS installation. CSS, JS and images were not showing up. Was due to the "Static Content" role not being installed in IIS 7.5.
You probably have Windows authentication enabled in your web.config. On a local machine, your Windows credentials are automatically passed and it works. On a live site, you are treated as an anonymous user (IE setting can control this, but don't modify this unless you really know what you are doing).
This causes the following:
This isn't broken, just working as intended, but to "fix" this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With