简体   繁体   English

CSS,JS 文件未加载 IIS 托管站点

[英]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:我尝试过的事情:

  1. Static content enabled Static 内容已启用
  2. Permissions provided for IUSR为 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.首先,确保 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.

相关问题 IIS 7.5 和 Razor 站点:CSS 和 JS 500 错误 - IIS 7.5 and Razor Site: 500 errors for CSS and JS CSS文件未在IIS8中加载,但在Visual Studio 2015中加载 - CSS files not loading in IIS8, but loads in Visual Studio 2015 使用代码检查 IIS 上托管的站点名称 - check the site name hosted on IIS using code 如何确保Angular2 / 4前端始终获取IIS中托管的更新的html,css和js? - How to ensure the Angular2/4 frontend always get the updated html, css and js hosted in IIS? iis托管的网站与本地网站不同 - iis hosted web site differs from local web site 我在本地iis上托管的网站无法加载图片,js和其他文件 - My website hosted in the local iis can't load images, js and other files HttpModule不会拦截IIS 5.1中的js和CSS文件 - HttpModule does not intercept js and css files in IIS 5.1 如何通过站点在IIS上的站点中更新文件? - How to update files in a site on IIS via the site? 如何让浏览器为https站点缓存CSS和JS文件? - How to let the browser cache css and js files for a https site? 如何获取 IIS 中托管的任何站点的服务器名称和托管站点名称? - How to get the server name and hosted site name of any site hosted in IIS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM