当我使用Handler.ashx从文件夹中显示图像,然后尝试通过右键单击它保存图像时,它会一直给我提供“另存为类型”选项的ASP.NET通用处理程序和处理程序名称作为文件名。
Bitmap target = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(target)) {
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.DrawImage(photo, 0, 0, width, height);
using (MemoryStream memoryStream = new MemoryStream()) {
target.Save(memoryStream, ImageFormat.Png);
OutputCacheResponse(context, File.GetLastWriteTime(photoPath));
using (FileStream diskCacheStream = new FileStream(cachePath, FileMode.CreateNew))
{
memoryStream.WriteTo(diskCacheStream);
}
memoryStream.WriteTo(context.Response.OutputStream);
}
}
以上是处理器。
ImageTiff.ImageUrl = "Handler.ashx?p=" + Parameter;
这是代码的实现。
我需要将其保存为图像名称,而不是handler.ashx处理程序。
filename=\"yourfilename.png\"
,否则Firefox可能会出现问题。至于使右键单击=>“另存为”起作用-没有机会这样做。 - Michael Stum