gpt4 book ai didi

c# - Html.Action - InsufficientExecutionStackException 异常

转载 作者:太空狗 更新时间:2023-10-30 00:32:35 24 4
gpt4 key购买 nike

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

最佳答案

@Html.Action正在执行指定的操作并以字符串形式返回该操作的结果。

如果您正在重新呈现 Index 操作,然后重新呈现相同的 View ,它只会一圈又一圈。

如果您需要链接,请改用 @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>

关于c# - Html.Action - InsufficientExecutionStackException 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16835595/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com