HomeController中没有调用的方法

时间:2013-03-10 19:24:57

标签: c# asp.net-mvc-4

我尝试从我的视图页面调用一个方法但是没有调用它。 我的Home Controller示例代码是

public ActionResult Sample(Guid id)
    {
        List<Images> imgList = ImagesManager.GetAlllImages();
        var bindlist = (from i in imgList where id == i.ImageId select i).ToList();
        return RedirectToAction("Index",bindlist);
    }

我尝试调用它的.cshtml页面(视图)代码是

<div class="product">
                            <a href="Sample/?Id=@item.ImageId" class="info">
                                <span class="holder">
                                    <img src="@item.ImagePath" alt="">
                                    <span class="dd" >@item.ImageName</span>
                                    <span class="author">by John Smith</span>

为什么不调用“Sample”方法。

错误是“找不到资源”

1 个答案:

答案 0 :(得分:1)

我认为这就是你要找的东西

@Html.ActionLink(
    "text for your link", 
    "Sample", // action method
    "Home",   // controller
    new { id = item.ImageId }, // your variable you want to pass
    null) 
相关问题