I have the following WebApi that returns MultipartContent to a client containing an image from a database and some extra data: -
public class PhotoController : ApiController
{
public HttpResponseMessage GetPhoto(Int32 personId)
{
var service = new PhotoService();
var photo = service.SelectPrimaryPhoto(personId);
if (photo == null)
return Request.CreateResponse(HttpStatusCode.NoContent);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
var content = new MultipartContent();
content.Add(new ObjectContent<Photo.Data>(photo, new JsonMediaTypeFormatter()));
content.Add(new StreamContent(photo.Image));
response.Content = content;
return response;
}
}
On the client, HttpResponseMessage.Content is displayed as a StreamContent type. How can I access it as a MultipartContent? The client is WPF, not a web browser.
source
share