I am trying to write a controller that creates and makes a HttpWebRequest to a service that returns an Image. I then want to return this image as a FileResult. How do I go about doing that. I have tried the code below but it returns a corrupted image instead of the full image:
public FileResult SomeAction()
{
var request = Make some request here
using (var response = (HttpWebResponse)request.GetResponse())
{
string contentType = response.ContentType;
return File(response.GetResponseStream(),contentType);
}
}
Thanks