0

I want to build a basic web app for accessing images I cant access normally. It works like this: let's say this image is not accessible on my network:

https://i.redd.it/n6y3rbn3qfm01.jpg

I will make a request to my app like this:

mywebapp.azurewebsites.net/Home/Mirror?url=https://i.redd.it/n6y3rbn3qfm01.jpg

And the controller will download the image and show it without client having to access i.reddit domain.

I tried doing this but it had 2 problems: it directly returns the file as download instead of showing it as an image in page and it only worked on my computer, not on Azure.

public ActionResult Mirror(String url)
{
    ViewBag.Url = url;

    Stream rtn = null;
    HttpWebRequest aRequest = (HttpWebRequest)WebRequest.Create(url);
    HttpWebResponse aResponse = (HttpWebResponse)aRequest.GetResponse();
    rtn = aResponse.GetResponseStream();

    return File(rtn, "image/jpeg", "Image_1");
}
marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
yigitserin
  • 493
  • 1
  • 4
  • 21

0 Answers0