【问题标题】:C sharp Text to jpg - how to change image extensionCSharp Text to jpg - 如何更改图像扩展名
【发布时间】:2011-06-24 14:30:32
【问题描述】:

我正在使用以下代码将文本即时转换为 jpg。

context.Response.ContentType = "图像/jpeg"; SaveAsJpeg(bitmap, context.Response.OutputStream, (long)100);

当我在互联网上显示页面时,图像表面看起来很好。但是当我右键单击并将图像保存为或将页面另存为时,我得到 ashx 作为文件扩展名。

如何获得 jpg 作为文件扩展名?

【问题讨论】:

  • 您是否将图像作为 ImageFormat.Jpeg 保存到 Response.OutputStream?

标签: c# image


【解决方案1】:
context.Response.AddHeader("Content-Disposition", "attachment; filename=your-name-here.jpg");

这告诉浏览器应该将文件保存为什么名称。

【讨论】:

  • 这也不起作用。实际上,我什至在发布这个问题之前就尝试过!
  • 你能用inline代替attachment试试吗?我试过了,它适用于 IE9 和 FF4。
猜你喜欢
  • 1970-01-01
  • 2022-07-18
  • 2013-08-17
  • 2014-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多