Visual Studio开发服务器中显示的图像,但不是IIS7

时间:2014-12-30 16:08:06

标签: css asp.net-mvc image visual-studio-2012 iis-7

在将我的MVC 5项目发布到IIS 7时,我遇到了使图像工作的问题。我有一个类似于下面的体型,似乎是通过显示白色背景而不是图像失败(它完全跳过灰色)

body {
background-color: grey;
background: transparent url("Images/Background.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
height: 100%;
}

我提出了Chrome开发工具,并查看了图像的实际链接,并手动添加了" /"然后删除它,图像显示正常,但刷新失败。除了下面定义的404错误之外,我在控制台中没有出现任何错误。

我也尝试了以下版本(其中一些版本的失败比其他版本更明显)

  • Images / Background.png(无错误)
  • /Images/Background.png(404错误)
  • 〜/ Images / Background.png(404错误)
  • ~Images / Background.png(404错误)

后者3抛出错误:

- http://10.96.90.65/Images/Background.png 404 (Not Found)
 - http://10.96.90.65/SITE/Content/~/Images/Background.png 404 (Not Found)
 - http://10.96.90.65/SITE/Content/~Images/Background.png 404 (Not Found)

我的适用虚拟文件结构如

  • /内容
  • /内容/图片/
  • /内容/主题/
  • /内容/ *。CSS
  • /图像/

我正在使用Visual Studio 2012和IIS 7 编辑:图像正在Internet Explorer中加载,但不是Chrome

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用html base tag

我之前遇到过一个问题,我无法访问IIS上的图像,但可以在本地运行时使用。我还认为有一个可以更改的IIS设置,但那对我来说当时没有可能,所以我从未研究过这个选项。

标题中包含以下内容:

<base href="~/" />

否则,您能告诉我们以下选项在IIS服务器上的实际效果吗?

  • Images / Background.png(无错误)
  • /Images/Background.png(404错误)
  • 〜/ Images / Background.png(404错误)
  • ~Images / Background.png(404错误)
相关问题