I have this child action in a controller
[ChildActionOnly]
public ActionResult GetImage(int id)
{
var photo = _Db.Photozs.Single(p => p.PhotozId == id);
string path = Server.MapPath("~/Photo"+photo.Url);
fs = new FileStream(path, FileMode.Open);
return new FileStreamResult(fs, photo.ContentType);
}
My razor view is :
@model IEnumerable
@{
ViewBag.Title = "Index";
}
@foreach (var item in Model)
{
<img class="img-polaroid" src="@Url.Action("GetImage",new{id=item.PhotozId})"/>
}
The problem I'm having is that when I remove d ChildActionOnlyAttribute from GetImage action the image renders in the view but when I add it it does not. I want this action to b child so it cannot be invoked directly by the user. Thanks
[ChildActionOnly]
public ActionResult GetImage(int id)
{
var photo = _Db.Photozs.Single(p => p.PhotozId == id);
string path = Server.MapPath("~/Photo"+photo.Url);
fs = new FileStream(path, FileMode.Open);
return new FileStreamResult(fs, photo.ContentType);
}
My razor view is :
@model IEnumerable
@{
ViewBag.Title = "Index";
}
@foreach (var item in Model)
{
<img class="img-polaroid" src="@Url.Action("GetImage",new{id=item.PhotozId})"/>
@item.Caption
The problem I'm having is that when I remove d ChildActionOnlyAttribute from GetImage action the image renders in the view but when I add it it does not. I want this action to b child so it cannot be invoked directly by the user. Thanks