把DB內(nèi)Binary格式圖檔轉(zhuǎn)出到Asp.Net MVC的View上顯示圖片
ASP.NET, Microsoft, MVCIf you run into a ASP.NET MVC site that needs to get images stored as binary data in a SQL database you can do the following to help you read these images and display them in your view.
The Controller
下面算是一個(gè)簡易型寫法,取出byte[]的image data,然後Respone.Write寫到View上,
記得要指定contentType,其實(shí)也可以轉(zhuǎn)成base64,再拋?zhàn)执角岸巳ィ岸嗽儆?/b>
<img> tag即可顯示,用base64格式的話記得img tag內(nèi)要指定為base64
The View
下面就簡單列出用img tag去包Url.Action把call回來的東西放到src內(nèi)顯示