日期:2014-05-17 浏览次数:20525 次
<a onclick="ExaminePictureFun('@name.Key')" href="javascript:void(0)" >图片链接为:</a>
<img id="imgPic" title="imgPicCake" alt="蛋糕照片!" />
ExaminePictureFun = function (val) {
$("#imgPic").attr("src", "/Order/Picture?PictureID=" + val);
}
public ActionResult Picture(string PictureID)
{
return new ImageResult()
{
byteStream = (byte[])dic[PictureID]
};
}
public class ImageResult : ActionResult
{
public ImageResult() { }
public byte[] byteStream;
//重写ExecuteResult
public override void ExecuteResult(ControllerContext context)
{
// 设置响应设置
context.HttpContext.Response.ContentType = "image/jpeg";
context.HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
context.HttpContext.Response.BufferOutput = false;
FileStream filestream = null;
// 将图像流写入响应流中
const int buffersize = 1024 * 32;
byte[] buffer = new byte[buffersize];
int count = filestream.Read(buffer, 0, buffersize);
while (count > 0)
{
&nb