当前位置: 动力学知识库 > 问答 > 编程问答 >

sql server - Display image from database with the type binary/byte[]

问题描述:

Ive stored an image with memorystream to my database, but now i want to display the image in the view but since its the type of binary i dont really know how and im trying to convert it from string. i think i have enough code in the controller which will enable me to display the image but i dont know how to display it.

another important thing is that i need to show this image in the _ViewStart.cshtml, so it will appear on everysite. (PageData["LogoUrl"] = "imagefromdatabase";)

this is how far ive been able to do:

 public void Show( Models.EditLogoModel MLogo, int id, object data)

{

var service = ServiceFactory.Instance.CreateLogoService();

if (data != null)

{

if (Request.QueryString["id"] != null)

{

Byte[] LOGO = MLogo.DBLogo.PicImgData;

Response.Buffer = true;

Response.Charset = "";

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.ContentType = MLogo.DBLogo.PicImgData.ToString();

Response.BinaryWrite(LOGO);

Response.Flush();

Response.End();

}

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: