Q:

Display page and picture in one request in MVC 3

I wondered if it is possible to show picture in a view without calling an action. The picture is displayed by using the following Razor code:
    <img class="photo" src="@Url.Action("GetImage", "Home", new { id = @Model.Id })" />

But retrieving picture from server requires an additional request.
Is it possible to "deploy" image in ViewBag and show it in view without calling server?
Thanks,

A:

Is it possible to "deploy" image in ViewBag and show it in view without calling server?

You could use the Data URI scheme. But be careful as it might not be supported by all browsers.
Example:
<img class="photo" src="data:image/png;base64,iVBORw0KG....." alt="" />

where src attribute of the image contains the Base64 encoded image that could come from ViewBag or a view model.

