MVC3 URL.Action没有在img标签中呈现我的图像

时间:2011-08-29 19:14:45

标签: image asp.net-mvc-3 filecontentresult

我的观点中有一张图片,如:

    <img width="150" height="150" scr="@Url.Action("GetImage", "Item")" />

我的控制器ItemController有这个方法:

    public FileContentResult GetImage(){
        var model = _itemService.GetItemImage(1);
        if(model != null && model.ImageData != null){
            return File(model.ImageData, model.ImageMimeType);
        }
        return null;
    }

当视图渲染时,我得到了我的图像的以下标记,但没有渲染图像:

    <img width="150" height="150" scr="/MyApp/ItemManagement/GetImage"/>

如果我在浏览器中输入此URL“http:// localhost / MyApp / ItemManagement / GetImage”,我会得到图片。我不确定这有什么问题。有人可以指出我的代码有什么问题吗?

提前致谢。 杰夫

1 个答案:

答案 0 :(得分:7)

图片属性应为src ...?