Search code examples
imageasp.net-mvc-3filecontentresult

MVC3 URL.Action not rendering my image in img tag


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/GetImage"/>

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


Solution

  • Image attribute should be src...?