2

I have a controller as follows that returns a byte[]

public class ImageController : Controller
    {
        public ActionResult Show(int id)
        {


            var proxy = new ServiceProxy();
            var imgData = proxy.GetCheckImage(id);
            return File(imgData, "image/tiff");
           }
    }

My view is as follows:

<img alt ="" src='@Url.Action("show", "image", new { id = 36 })'/>

I have hard coded the image id for debug purposes.

On the browser in chrome/ie I get a x where the image needs to be displayed. But if I go directly to the controller url http://localhost/website/image/show/id=36, the image gets downloaded fine to the local machine.I have tried creating a separate ActionResult in the same controller which is used to display other data without any luck. This is a Win7/IIS7 local dev. environment.

kolhapuri
  • 1,581
  • 4
  • 20
  • 31

2 Answers2

3

Tiff is not supported by most browsers. The solution is to convert the Tiff to a Png file.

This post has the solution to your problem:

Render image to the screen from MVC controller

General Grievance
  • 4,555
  • 31
  • 31
  • 45
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
1

Is Tiff supported by Chrome/IE? I don't think it is...

Sam
  • 1,725
  • 1
  • 17
  • 28