Html.Action - InsufficientExecutionStackException

时间:2013-05-30 12:02:31

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

当我使用@Html.Action("Index") InsufficientExecutionStackException时,为什么?这是一个简单的mvc命令行。

1 个答案:

答案 0 :(得分:8)

@Html.Action正在执行指定的操作,并将该操作的结果作为字符串返回。

如果你重新渲染Index动作然后重新渲染同一个视图,那么它只是圆形和圆形。

如果您想要链接,请改用@Html.ActionLink("Index")

以下是这种情况的一个例子:

public class HomeController : Controller
{
   public ViewResult Index()
   {
      return View();
   }
}

这是Razor代码:

<html>
<head>
   <title>Index</title>
</head>
<body>
    <!-- Causes an infinite loop; embedding the same action inside itself -->
    @Html.Action("Index")
</body>
</html>
相关问题