I guess it's something very straight forward but I can't find out how to do it. In my controller I have:
public ViewResult ShowForm()
{
ViewBag.Title = Resources.ApplicationTitle;
ViewBag.LabelStatus = Resources.Status;
//Logo
ViewBag.Logo =@"C:\Images\Logo.png";
return View("ShowForm");
}
And in my view I try this:
<div id="drawForm">
<img src="@ViewBag.Logo" alt="Logo" />
</div>
However when I run this I just get the "Logo" text.
You need a ImageController to render that.
See this:
ASP.NET MVC3: Image loading through controller
and this: Can an ASP.NET MVC controller return an Image?
once you have a controller you can render as follows:
in your views:
Try this:
Use
Server.MapPath
to get the correct path of the image. Suppose your images folder is inside theContent
folder that is normally included in an MVC project. You can do something like this:And you don't have to change the code in your view.