HttpPost返回视图后出现System.StackOverflowException-ASP MVC [英] System.StackOverflowException after HttpPost returning view - asp mvc

查看:84
本文介绍了HttpPost返回视图后出现System.StackOverflowException-ASP MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The error that I get is this (no more info) : System.StackOverflowException

项目中的所有内容都可以正常工作,但是一旦我发布了数据,之后,它应该返回视图,我得到了这个错误

Everything in my project is working fine but as soon as I post a data and after that, it should return view I get that error

,并且在我删除

正常工作

@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

我不知道加载局部视图有什么问题或在HttpPost之后返​​回视图的问题只是它在其他页面中的分叉,但是当我尝试使用HTTP HTTP表单操作访问视图时出现该错误

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的窗体,并且在触发之后,我们应该获取创建的视图,但它只返回上述错误

and about the HttpPost, let assume that there is view "A" that had the Form that is HttpPost and after that fires, we should get the created view BUT it just returns the above error

推荐答案

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

just get your info in LayoutView if you using the DI first inject your repo

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

然后代替

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

使用部分

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

这篇关于HttpPost返回视图后出现System.StackOverflowException-ASP MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆