title: c# can an API return HttpWebResponse
body: <p>what I am trying to do -I guess- is use an API as a proxy. It worked with Fiddler and there was the idea.</p>
  
  <p>I have a website and wish to show another into an iframe. But i need to remove the 'no-open' header to do that. </p>
  
  <p>So the plan is:
  Sent a url string to the API from my site, the API makes a request to that url, gets the response, and without saving the page just changes a few headers and respond back to my website.</p>
  
  <p>Problem:
  It keeps returning a json. I tried to return the html code as a string, but then my website will not render it into iframe. </p>
  
  <p>This is my code.</p>
  
  <pre><code> public class ProductsController : ApiController
  {
      public HttpWebResponse GetProductsByCategory(string url, int edit)
      {            
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
          request.Method = WebRequestMethods.Http.Get;
          request.ContentType = "text/html";
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
          //
          if (edit == 1)
          {                              
              response.Headers.Set("Content-Disposition", "");
              response.Headers.Set("X-Download-Options", "");               
          }
          response.Headers.Set("Content-Type", "text/html");
          response.Headers.Set("APIflag", "Hi!");
  
          Stream theHTML = response.GetResponseStream();
          StreamReader objReader = new StreamReader(theHTML);
          string myHTML = objReader.ReadToEnd();
  
          System.Diagnostics.Debug.WriteLine("url was: "+url); //is OK
          System.Diagnostics.Debug.WriteLine("edit flag was: " +edit); //is OK
          System.Diagnostics.Debug.WriteLine(myHTML); //is OK
  
          return response;
      }
  }
  </code></pre>