【发布时间】:2013-12-31 12:50:45
【问题描述】:
这是我的模型
public class MyModel
{
public System.Drawing.Image MyImage { get; private set; }
public MyModel(System.Drawing.Image myImage)
{
this.MyImage = myImage;
}
}
这是我的看法
@model MyModel
@using MyNamespace.MyModels;
@{
ViewBag.Title = "title";
}
<img id="11111" src="@Model.MyImage" alt="Hello alt text" />
这是我的控制器
public class MyController : Controller
{
public ActionResult Index()
{
Image img = GoAndGetImage(55);
MyModel model = new MyModel(img);
return View(model);
}
private System.Drawing.Image GoAndGetImage(int id)
{
// Retrieve bytesArray from sql db, convert to System.Drawing.Image type
}
}
但我只能看到 Hello alt text 而不是真实图像。我做错了什么?
【问题讨论】:
-
读取生成的源码。您需要使用
data:URI,或发出单独的 HTTP 请求。
标签: c# asp.net-mvc-3