无法在浏览器Mozilla Firefox,Chrome中显示图像

时间:2011-09-15 03:05:23

标签: asp.net asp.net-mvc

我的Helper.cs代码如下所示:

public static string NoImagePath { get { return "file:///W:/images/noimage.png"; } }

在视图中:

<% if (!string.IsNullOrEmpty(Model.Item[i].PictureName)){ %>
<img width="135px" height="100px" src="<%: HelperClass.CheckImageUrlExist(Model.Item[i].PictureName)%>" alt="<%: Model.Item[i].Name %>" /> 
<%}else{ %>
<img width="135px" height="100px" src="<%:HelperClass.NoImagePath %>" alt="No Image"/>           
<%} %>

所有这些图像只能在IE中显示,但其他浏览器如mozilla firefox,chrome ..则不能。任何人都可以解决这个问题吗?

感谢。

1 个答案:

答案 0 :(得分:0)

使用相对路径。由于安全原因,大多数浏览器不支持file:// URI(谷歌,我太懒了链接),所以如果你把你的图像放到一个文件夹中并绝对或相对地引用它们,HTML应该呈现在所有浏览器中都很好。

相关问题