System.StackOverflowException HttpPost 返回视图后 - asp mvc

System.StackOverflowException after HttpPost returning view - asp mvc

我得到的错误是这样的(没有更多信息): System.WhosebugException

我的项目中的一切都工作正常,但一旦我 post 一个数据,然后,它应该 return 查看我得到那个错误

并且在我删除

后立即在我的布局中

部分工作正常

@Html.Action("TuorMenu", "Home", new { area = "Site" })

简化布局

@{
Layout = null;
}
<!DOCTYPE html>
html dir="rtl" lang="fa">
<head>
</head>
<body>
    @Html.Action("TuorMenu", "Home", new { area = "Site" })
    @RenderBody()
</body>
</html>

和像这样创建的部分

    [HttpGet]
    [OutputCache(Duration = 86400, VaryByParam = "none")]
    [ChildActionOnly]
    public ActionResult TuorMenu()
    {
        MenuViewModel vmg = new MenuViewModel();

        vmg.TourGroup = _repoTourGroup.Where(p => p.Id != 15).ToList();
        //vmg.BlogGroup = _repoBlogGroup.Select();
        return PartialView("_TuorMenu", vmg);
    }

...

@model test.ViewModels.Home.MenuViewModel

@{
    Layout = null;
}

 .......loading menu

I don't know is there anything wrong with the loading partial view or its just problem with returning view after HttpPost be its just forking fin in other pages but get that error when I try to access a view with a form HTTP post action

关于 HttpPost, 假设有一个视图 "A" 具有 HttpPost 的表单,然后触发,我们应该得到创建的视图,但它只是 return 上面的错误

只需在 LayoutView 中获取您的信息 如果你使用 DI 首先注入你的 repo

 var _repoMenu = DependencyResolver.Current.GetService<IMenuRepository>();
 var MenuModel = _repoMenu.Select();

然后而不是

@Html.Action("TuorMenu", "Home", new { area = "Site" })

使用部分

@Html.Partial("~/Areas/.../_TourMenu.cshtml",MenuModel)