开发者

MVC3 URL.Action not rendering my image in img tag

开发者 https://www.devze.com 2023-03-31 19:04 出处:网络
I have an image in my view, as: <img width=\"150\" height=\"150\" scr=\"@Url.Action(\"GetImage\", \"Item\")\" />

I have an image in my view, as:

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

My controller, ItemController, has this method:

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

When the view renders, I get the following markup for my image but no image is rendered:

    <img width="150" height="150" scr="/MyApp/ItemManagement/Ge开发者_Go百科tImage"/>

If I type this url 'http://localhost/MyApp/ItemManagement/GetImage' in the browser, I get the image. I'm not sure what's wrong with this. Could someone point out what is wrong with my code please?

Thanks in advance. Jeff


Image attribute should be src...?

0

精彩评论

暂无评论...
验证码 换一张
取 消