我创建了一个将 URL(HTML) 的内容转换为图像 (JPG) 的操作,然后将其返回给我,但是,浏览器正在下载它而不是显示。
图像是动态生成的,我没有在硬盘中。
我的代码如下:
[AllowAnonymous]
public FileResult URLToImage(string url)
{
// In some cases you might want to pull completely different URL that is not related to your application.
// You can do that by specifying full URL.
UrlAsImage urlImg = new UrlAsImage(url)
{
FileName = Guid.NewGuid().ToString() + ".jpg",
PageHeight = 630,
PageWidth = 1200
};
return File(urlImg.BuildFile(this.ControllerContext), "image/jpg", urlImg.FileName);
}
我需要做什么才能在浏览器中显示它而不是下载它?