(.ashx) -. ashx , ( PNG ) :
using System;
using System.Web;
using System.IO;
namespace ASHXTest
{
public class GetLetter : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string fileName = context.Request.MapPath(string.Format("{0}.png",
context.Request.QueryString["letter"]));
FileStream stream = new FileStream(fileName, FileMode.Open,
FileAccess.Read);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
context.Response.ContentType = "image/png";
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
Content-Disposition, :
context.Response.AddHeader("Content-Disposition",
"attachment;filename=\"letter.png\"");
source
share