这里是我的模型无法显示图像
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
}
}
但我只在这里看到你好ALT文字而不是真实的图像。我究竟做错了什么?
阅读生成的来源。您需要使用'data:'URI,或者创建一个单独的HTTP请求。 – SLaks