我想这是非常直截了当的事情,但我不知道该怎么做。在我的 Controller 中,我有:
public ViewResult ShowForm()
{
ViewBag.Title = Resources.ApplicationTitle;
ViewBag.LabelStatus = Resources.Status;
//Logo
ViewBag.Logo =@"C:\Images\Logo.png";
return View("ShowForm");
}
在我看来,我试试这个:
<div id="drawForm">
<img src="@ViewBag.Logo" alt="Logo" />
</div>
但是,当我运行它时,我只会得到“ Logo ”文本。
最佳答案
试试这个:
ViewBag.Logo = Url.Content("~/Content/Images/Logo.png");
关于asp.net-mvc-3 - 使用 ASP.NET MVC 3 中的 ViewBag 从 Controller 传递图像并显示在 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16142526/