Display Image using ashx Handler

前端 未结 3 586
[愿得一人]
[愿得一人] 2020-12-02 00:33

I have the following image in my aspx page


 \" 


         


        
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-02 01:10

    Try the following in your ProcessRequest method:

    context.Response.ContentType = "image";
    
    using (System.IO.MemoryStream str = new System.IO.MemoryStream(objData.ToArray(), true))
    {
           str.Write(objData.ToArray(), 0, objData.ToArray().Length);
           Byte[] bytes = str.ToArray();
           context.Response.BinaryWrite(bytes);
    }
    

    where objData is the value you are reading from the database

提交回复
热议问题