2012-03-22 63 views
0

錯誤如何從字節顯示圖像?

編譯器錯誤消息:CS1502:到 過載的最適當的方法 'System.Web.WebPages.WebPageExecutingBase.Write (System.Web.WebPages.HelperResult)' 具有一些無效參數

@ImageResultHelper.Image<ShowcaseController>(c => c.FileContentResult(), 200, 50, "Current time") 

,我需要發送新{字節= item.ImageItems}到FileContentResult

+1

什麼是ImageResultHelper? – jrummell 2012-03-22 13:57:11

+0

我發現這個課程/ – 2012-03-22 15:12:34

+1

除非您告訴我們更多關於它的信息,否則我們無法提供幫助...... – jrummell 2012-03-22 15:13:11

回答

4

我們做事的方式,是我們返回FileContentResult

public FileResult Get() 
{ 
    return new FileContentResult(image.Bytes, image.ContentType); 
} 

然後我們設置圖像的src這個動作:

<img src="/Controller/Get/" alt="Whatever" /> 

這樣你就可以緩存結果。