开发者

ASP.Net MVC3 Rendering Database stored images

开发者 https://www.devze.com 2023-02-14 13:46 出处:网络
I have a controller as follows that returns a byte[] public class ImageController : Controller { public ActionResult Show(int id)

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 dow开发者_如何转开发nloaded 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.


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


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

0

精彩评论

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