Shai Cohen
Shai Cohen

Reputation: 6249

How do I display an image returned from MVC4 Web API

We have a Web API (MVC4) application that returns images from the database. I have verified that the call to the Web API does produce a valid image.

Here is the Fiddler result showing that the image is returned properly: Fiddler API Call:

I tried setting an image element with the same source as the call, but that didn't work:

<img id="img" src="http://localhost/Seek/api/artifactcontent/?userName=XXXXX&password=XXXXXX&id=15-00931-27" />

What am I doing wrong?

Upvotes: 0

Views: 1095

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87228

You request in Fiddler is a POST request; the <img> tag sends a GET request. If you want to display images using <img> tags, you'll need to make your action accept GET requests instead of (or in addition to) POST.

Upvotes: 2

Related Questions