string mac = "";
try
{
mac = (context.Request["mac"]);
mac = mac.Replace("-", "");
}
catch {
Bitmap bitmap = null;
byte[] cachedData = null;
if (bitmap != null)
{
MemoryStream stream = new MemoryStream();
bitmap.Save(stream, ImageFormat.Png);
cachedData = stream.ToArray();
context.Cache.Insert(kehuKey, cachedData, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);
context.Response.ContentType = "image/jpeg";
context.Response.OutputStream.Write(cachedData, 0, cachedData.Length);
}
}
try
{
mac = (context.Request["mac"]);
mac = mac.Replace("-", "");
}
catch {
Bitmap bitmap = null;
byte[] cachedData = null;
if (bitmap != null)
{
MemoryStream stream = new MemoryStream();
bitmap.Save(stream, ImageFormat.Png);
cachedData = stream.ToArray();
context.Cache.Insert(kehuKey, cachedData, null, DateTime.Now.AddSeconds(60), Cache.NoSlidingExpiration);
context.Response.ContentType = "image/jpeg";
context.Response.OutputStream.Write(cachedData, 0, cachedData.Length);
}
}
bitmap 先写入到流,然后写到Cache,在将Cache中的数据发出