CSS图片在ASP.NET MVC中不显示 [英] CSS images not showing in ASP.NET MVC

查看:1420
本文介绍了CSS图片在ASP.NET MVC中不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET MVC应用程序,我通过CSS引用背景图像。当我在开发环境中运行它,它们显示了罚款。但是,当我部署它(使用IIS 7.5)图像不会加载。我已经试过相对路径的每个组合和背景 / 背景图片 CSS标签,但没有任何工程。这里是我的文件结构和CSS:

In my ASP.NET MVC application, I am referencing background images via CSS. When I run it in the dev environment, they show up fine. But when I deploy it (using IIS 7.5) the images do not load at all. I have tried every combination of relative paths and background/background-image CSS tags, but nothing works. Here is my file structure and CSS:

文件structrue:

File structrue:

Content  
    CSS file  
images  
    image.png  

CSS:

background-image: url(/images/bsb_header2.png);

我也试过 ../图像/ bsb_header2.png ../../图像/ bsb_header2.png 无济于事。

什么是真正奇怪的是,当我试图去直接图像(即 www.website.com/images/image.png ),我重定向到一个登录页面。或许有我错过了一些访问或安全设置?我还没有对登录控件做任何事(默认帐户视图和控制器都在我的项目,但我还没有与他们做任何事情),我可以看到我的所有其他网页就好了。

What is really strange is when I try to go to the image directly (i.e. www.website.com/images/image.png), I am redirected to a login page. Perhaps there is some access or security setting I'm missing? I haven't done anything with login controls yet (the default account view and controller are in my project but I haven't done anything with them yet) and I can view all my other pages just fine.

更新:我终于想通了。有问题的图像文件进行加密。右键单击图像文件,然后导航到属性,单击常规选项卡上的高级按钮,取消选中加密内容以便保护数据,单击确定,确定。

Update: I FINALLY figured it out. The image file in question was encrypted. Right click the image file and navigate to properties, click the advanced button on the general tab, uncheck "Encrypt contents to secure data", click OK, OK.

时,我注意到的文件名是绿色的Windows资源管理器关闭终于来了一角。我看到绿色的文件名都没有问题的时候,所以我不认为它是什么。这时我才发现这是在整个Web应用程序文件夹中唯一的绿色文件。把两者在一起,它立即工作。谢谢大家对你的帮助。

The tip off finally came when I noticed the file name was green in Windows Explorer. I see green file names all the time with no problems so I didn't think anything of it. Then I noticed it was the only green file in the entire web app folder. Put two and two together and it worked instantly. Thanks everyone for your help.

推荐答案

我终于想通了。有问题的图像文件进行加密。右键单击图像文件 - >属性 - >高级按钮常规选项卡上 - >取消选中加密内容以便保护数据 - >确定 - >确定

I FINALLY figured it out. The image file in question was encrypted. Right click the image file -> properties -> advanced button on general tab -> uncheck "Encrypt contents to secure data" -> OK -> OK.

时,我注意到的文件名是绿色的Windows资源管理器关闭终于来了一角。我看到绿色的文件名都没有问题的时候,所以我不认为它是什么。这时我才发现这是在整个Web应用程序文件夹中唯一的绿色文件。把2和2在一起,它立即工作。谢谢大家对你的帮助。

The tip off finally came when I noticed the file name was green in windows explorer. I see green file names all the time with no problems so I didn't think anything of it. Then I noticed it was the only green file in the entire web app folder. Put 2 and 2 together and it worked instantly. Thanks everyone for your help.

这篇关于CSS图片在ASP.NET MVC中不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆