public ActionResult Overview(int subId, string countrycod)
{
byte[] objByteArray =(byte[]) objResponse.Data;
//return View();
System.IO.MemoryStream imagestream = new System.IO.MemoryStream();
imagestream.Write(objByteArray, 0, objByteArray.Length);
//return new FileStreamResult(new System.IO.MemoryStream(objByteArray,true),"image/png");
return new FileStreamResult(imagestream, "image/png");
}
问问题
2112 次
1 回答
3
你不需要内存流,你可以直接返回字节数组:
public ActionResult Overview(int subId, string countrycod)
{
byte[] objByteArray = (byte[])objResponse.Data;
return File(objByteArray, "image/png");
}
然后在视图内部使用一个<img>
标签,您将指向Overview
控制器操作:
剃刀:
<img src="@Url.Action("Overview", "SomeController", new { subId = 123, countrycod = "en-US" })" />
网络表单:
剃刀:
<img src="<%= Url.Action("Overview", "SomeController", new { subId = 123, countrycod = "en-US" }) %>" />
于 2012-07-10T05:54:38.317 回答