我有这个解决方案,可以在我使用 Visual Studio 2012 .Net 4.5 的开发工作站上完美运行。没有 IIS 更改。它基本上是 C# 抓取网页并将其转换为 bmp。我不确定我的问题是否是我正在尝试写入文件系统。
这就是我在 Azure 中得到的。而且我正在阅读它可能是 Azure 中的限制/限制(如果是这种情况,我会非常失望)
502 - Web 服务器在充当网关或代理服务器时收到无效响应。
我认为这段代码的问题是:
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();
}
或者可能使用 image.save (这可能是下一个问题)。
image.Save(Server.MapPath("~") + "/output/"+filename);
我们的预算很低,并试图保持我们的托管网站简单且便宜。宁愿不必构建工作进程或使用 Azure 的存储功能。
===
更新:
我不认为我的问题是保存,但确实认为这将是 Azure 上的问题。此外,作为测试,我创建了一个处理程序 ashx,它将图像流返回到 html img 标记。这在本地也很有效,但在 Azure 上我只得到红色 X。不知道这是怎么回事。