[英]CSS,JS files not loading for IIS hosted site
My .net application when compiled in Visual studio through IIS express, works perfectly fine.通过 IIS express 在 Visual Studio 中编译时,我的 .net 应用程序运行良好。 The style sheets are getting loaded correctly.
样式表正在正确加载。 But when I host the application in IIS, the style sheets are not getting loaded correctly.
但是当我在 IIS 中托管应用程序时,样式表没有正确加载。 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:我尝试过的事情:
First, make sure CSS and js mime type is available and the mime types are correct.首先,确保 CSS 和 js mime 类型可用且 mime 类型正确。
then check the static handler mapping.然后检查 static 处理程序映射。
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. 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;
通常,人们使用相对路径名来引用 HTML 文件中的任何类型的文件; and the relative path should be a path relative to the location of a using file, HTML, .aspx, etc. Just check it up.
并且相对路径应该是相对于使用文件,HTML,.aspx等位置的路径。只需检查一下。
if you still face issue then try to run failed requests tracing in iis:如果您仍然遇到问题,请尝试在 iis 中运行失败的请求跟踪:
http://www.iis.net/learn/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-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.
对我有用的是,我将 web.config 上的“域”编辑为“localhost”到“localhost/projectfolder”并且它有效。 Additionally I edited the Static handler and re-saved it.
此外,我编辑了 Static 处理程序并重新保存它。 so it worked!
所以它奏效了!
Look if you have set something like in your head of index.html.看看你是否在 index.html 的头部设置了类似的东西。
<base href="/" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.