简体   繁体   中英

CSS,JS files not loading for IIS hosted site

My .net application when compiled in Visual studio through IIS express, works perfectly fine. The style sheets are getting loaded correctly. But when I host the application in IIS, the style sheets are not getting loaded correctly. I found a lot of similar questions but none of them is working in my case. I am seeing the below error:

在此处输入图像描述

Things I tried:

  1. Static content enabled
  2. Permissions provided for IUSR
  3. Anonymous authentication for App pool identity has been enabled

First, make sure CSS and js mime type is available and the mime types are correct.

then check the static handler mapping.

在此处输入图像描述

Both jQuery and CSS files are purely client-side entities, so check up the presence of the files and their path names in each HTML file using jQuery and CSS. Normally, people use relative path names to reference any kind of files in HTML files; and the relative path should be a path relative to the location of a using file, HTML, .aspx, etc. Just check it up.

if you still face issue then try to run failed requests tracing in iis:

http://www.iis.net/learn/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis

Thanks all for helping me with answers and for down voting my question. I tried all the options mentioned in this question and other related questions. What worked for me was, I edited the 'domain' on my web.config as 'localhost' to 'localhost/projectfolder' and it worked. Additionally I edited the Static handler and re-saved it. so it worked!

Look if you have set something like in your head of index.html.

<base href="/" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM