Html 加载资源失败:服务器响应状态为 404(未找到)错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15824552/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:13:18  来源:igfitidea点击:

Failed to load resource: the server responded with a status of 404 (Not Found) error in server

html.netcss

提问by Saranya

I'm trying to load up image in my Image Folder, but it's not working.

我正在尝试在我的图像文件夹中加载图像,但它不起作用。

Upon debugging, I see this error:

调试时,我看到这个错误:

Failed to load resource: the server responded with a status of 404 (Not Found)     

My image coding is in .css file that is,

我的图像编码在 .css 文件中,即

background: url("../Images/bgbody.png") no-repeat;    

What am I doing wrong here?

我在这里做错了什么?

回答by Dai

Use your browser's network inspector (F12) to see when the browser is requesting the bgbody.png image and what absolute path it's using and why the server is returning a 404 response.

使用浏览器的网络检查器 (F12) 查看浏览器何时请求 bgbody.png 图像及其使用的绝对路径以及服务器返回 404 响应的原因。

...assuming that bgbody.png actually exists :)

...假设 bgbody.png 确实存在:)

Is your CSS in a stylesheet file or in a <style>block in a page? If it's in a stylesheet then the relative path must be relative to the CSS stylesheet (not the document that references it). If it's in a page then it must be relative to the current resource path. If you're using non-filesystem-based resource paths (i.e. using URL rewriting or URL routing) then this will cause problems and it's best to always use absolute paths.

您的 CSS 是在样式表文件中还是在<style>页面的块中?如果它在样式表中,则相对路径必须相对于 CSS 样式表(而不是引用它的文档)。如果它在一个页面中,那么它必须是相对于当前资源路径的。如果您使用非基于文件系统的资源路径(即使用 URL 重写或 URL 路由),那么这将导致问题,最好始终使用绝对路径。

Going by your relative path it looks like you store your images separately from your stylesheets. I don't think this is a good idea - I support storing images and other resources, like fonts, in the same directory as the stylesheet itself, as it simplifies paths and is also a more logical filesystem arrangement.

按照您的相对路径,您似乎将图像与样式表分开存储。我不认为这是一个好主意 - 我支持将图像和其他资源(如字体)存储在与样式表本身相同的目录中,因为它简化了路径并且也是更合乎逻辑的文件系统排列。

回答by Qasim Bataineh

By default, IUSR account is used for anonymous user.

默认情况下,IUSR 帐户用于匿名用户。

All you need to do is:

您需要做的就是:

IIS -> Authentication --> Set Anonymous Authentication to Application Pool Identity.

IIS -> 身份验证 --> 将匿名身份验证设置为应用程序池标识。

Problem solved :)

问题解决了 :)

回答by TheEwook

It just means that the server cannot find your image.

这只是意味着服务器找不到您的图像。

Remember The image path must be relative to the CSS file location

记住图像路径必须相对于 CSS 文件位置

Check the path and if the image file exist.

检查路径以及图像文件是否存在。