简体   繁体   中英

Html.Action - InsufficientExecutionStackException

When i use @Html.Action("Index") the InsufficientExecutionStackException is throw, why? it's a simple mvc command line.

The @Html.Action is executing the action specified and returning the result of that action as a string.

If you are re-rendering the Index action that then re-renders this same view, its just going round and round and round.

If you want a link, use @Html.ActionLink("Index") instead.

Here is an example of this occurring:

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

And this is the Razor code:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM