title: Azure 502 errors .. trying new WebBrowser() and/or image.Save()
body: <p>I have this solution that works perfectly on my development workstation using Visual Studio 2012 .Net 4.5. No IIS changes. It's basically C# that grabs a webpage and turns it into bmp.  I'm not sure if my problem is that I'm trying to write to filesystem.  </p>
  
  <p>This is what I get in Azure. And I'm reading it might be a limitation/restriction in Azure (Very disappointed if that is the case)</p>
  
  <p><em><strong>502 - Web server received an invalid response while acting as a gateway or proxy server.</em></strong></p>
  
  <p>I figure my problem with this code:</p>
  
  <pre><code> public Bitmap GenerateThumbnail()
      {
          Thread thread = new Thread(new ThreadStart(GenerateThumbnailInteral));
          thread.SetApartmentState(ApartmentState.STA);
          thread.Start();
          thread.Join();
          return ThumbnailImage;
      }
      private void GenerateThumbnailInteral()
      {
          WebBrowser webBrowser = new WebBrowser();
          webBrowser.ScrollBarsEnabled = false;
          if (this.Method == ThumbnailMethod.Url)
              webBrowser.Navigate(this.Url);
          else webBrowser.DocumentText = this.Html;
          webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
          while (webBrowser.ReadyState != WebBrowserReadyState.Complete) Application.DoEvents();
          webBrowser.Dispose();
      }
  </code></pre>
  
  <p>or maybe with image.save (which might be a problem next).</p>
  
  <pre><code>image.Save(Server.MapPath("~") + "/output/"+filename);
  </code></pre>
  
  <p>We are low budget and trying to keeping our hosted site simple and inexpensive. Would rather not have to build a worker process or use storage features of Azure.</p>
  
  <p>===</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I don't think my issue is the Save, but do think that will be an issue on Azure. Additionally, as a test, I created a handler ashx that returns a image stream to a html img tag. That too works great locally, but on Azure I just get red Xs. Not sure what's up with that.</p>