Hi , Im not able to see the Image in the Http Response ,Below is my code . Can anyone suggest on how to download the Image . Thanks in Advance .
[HttpGetAttribute]
public HttpResponseMessage Download(Guid Id)
{ DbConnection db = new DbConnection();
if (Id == Guid.Empty) { throw new HttpResponseException(HttpStatusCode.NotFound); }
var TestQuery = db.tblTest.Where(P => P.TestID == (Id)) .Select(x => x.Photo).Single();
var response = new HttpResponseMessage(HttpStatusCode.OK);
{
response.Content = new PushStreamContent((outputStream, httpContent, transpContext)
=>
{
using (outputStream)
{
using (Stream StrContent = new MemoryStream(TestQuery))
{
StrContent.CopyTo(outputStream, totalLength);
}
}
}, "Image/png");
};
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "PhotoName.png"
};
response.Content.Headers.ContentType = new MediaTypeHeaderValue("Image/png");
return response;
}