Try this:
context.Response.WriteFile(context.Server.MapPath("~/Content/Images/palmtree.jpg"));
Without calling MapPath
the handler will look up the image in application's bin
directory.
Since you're using MVC framework there's a more consistent way (you don't need to implement your own handler):
public class HelloController : Controller
{
public ActionResult ShowImage(int id)
{
var fileName = "palmtree.jpg";
var rawFile = LoadFile(); //Assuming, LoadFile() returns byte[]
return File(rawFile, MimeMapping.GetMimeMapping(fileName), fileName);
}
}
View:
<img src="@Url.Action("ShowImage", "Hello", new { id = 1 })" alt="Dynamic Image" />