没有来自ChildAction的图片 [英] No Image from ChildAction

查看:82
本文介绍了没有来自ChildAction的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制器中有这个孩子的动作

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<okay.models.photoz>

@{
    ViewBag.Title = "Index";
}
<<div class="container-fluid">

    @foreach (var item in Model)
    {
        <div class="pull-left span3">
            <img class="img-polaroid" src="@Url.Action("GetImage",new{id=item.PhotozId})"/>
            <div class="text-center">@item.Caption</div>
        </div>
    }
</div>







我遇到的问题是当我从GetImage动作中删除d ChildActionOnlyAttribute时,图像会在视图中呈现,但是当我添加它时它不会。我希望这个动作对于孩子,所以不能由用户直接调用。谢谢



添加的代码块[/编辑]




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

Code blocks added[/Edit]

推荐答案

伙计们我还没有解决这个问题帮助
Guys I'm yet to solve this pls help


这篇关于没有来自ChildAction的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆