简体   繁体   English

局部视图:mscorlib.dll中发生了'System.StackOverflowException'类型的未处理异常

[英]Partial View: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

I know there are numerous posts already about this but i couldn't seem to fix the error. 我知道已经有很多关于此的帖子,但是我似乎无法修复该错误。

I am getting the above error (Title) in my Partial View which i believe means i have an infinite loop but i am not sure why this is happening. 我在我的局部视图中遇到上述错误(标题),我认为这意味着我有一个无限循环,但我不确定为什么会这样。 Please see below: 请看下面:

HomeController HomeController的

public ActionResult UserTable()
        {
            manager = new Manager();
            var data = manager.GetAllUsers();
            var userDetails = from u in data
                              select new UserDetail
                              {
                                  UserID = u.Id,
                                  Username = u.Name,
                                  UserLogin = u.Login,
                                  FirstName = u.FirstName,
                                  Surname = u.Surname,
                                  Email = u.Email,
                                  Active = Convert.ToInt32(u.Active),
                                  RightID = u.RightsId,
                                  GroupID = u.GroupsId,
                              };
            return View(userDetails.ToList());
        }

UserTable (PartialView) UserTable(PartialView)

@model IEnumerable<WebApplication1.Models.UserDetail>
@Html.Action("UserTable")
<br />
<div>
    <table class="table">
        <thead>
            <tr>
                //Table Headers
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    //Various @Html.DisplayFor()
                </tr>
            }
        </tbody>
    </table>
</div>

Index (View) 索引(查看)

@{Html.RenderPartial("UserTable");}

If you want me to clarify anything or you want any further details please do not hesitate to ask. 如果您想让我澄清任何事情,或者想要进一步的细节,请随时提出。 Thank you in advance. 先感谢您。

PS The error is occuring in the UserTable Method. PS该错误发生在UserTable方法中。

So I found a solution to my problem with the help of the hints from Stephen and Alexander in the comments. 因此,借助Stephen和Alexander在评论中的提示,我找到了解决问题的方法。 For me if I used Render Partial it didn't execute the Method for each partial view therefore returning null which is why i tried the Html.Action, but this causes an infinite loop, however if I use Render Action then the solution will execute the Methods, Hope this helps anyone that has the same problem. 对我来说,如果我使用Render Partial,则它不会为每个局部视图执行Method,因此返回null,这就是为什么我尝试了Html.Action的原因,但这会导致无限循环,但是如果我使用Render Action,则解决方案将执行方法,希望这对有相同问题的任何人有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mscorlib.dll中发生了未处理的“System.StackOverflowException”类型异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 发生mscorlib.dll错误时发生未处理的“System.StackOverflowException”类型异常? - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll error occurred? 调用递归函数期间,mscorlib.dll中发生了&#39;System.StackOverflowException&#39;类型的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll during calling recursive function 错误:mscorlib.dll中发生了&#39;System.StackOverflowException&#39;类型的未处理异常 - Error: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll RedisClientManager,mscorlib.dll中发生未处理的“System.StackOverflowException”类型异常 - RedisClientManager, An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll C# - 实体框架 - mscorlib.dll中发生未处理的“System.StackOverflowException”类型异常 - C# - Entity Framework - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll 在启动我的MVC3应用程序时,在mscorlib.dll中出现“类型&#39;System.StackOverflowException&#39;的未处理异常”? - On starting my MVC3 application, getting “An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll”? WPF telerik TreeView控件中的mscorlib.dll发生类型为&#39;System.StackOverflowException&#39;的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll in WPF telerik TreeView Control 对三个整数数组进行排序时,mscorlib.dll中发生了类型为&#39;System.StackOverflowException&#39;的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll when sorting array of three integers mscorlib.dll asp.net-mvc中发生类型为&#39;System.StackOverflowException&#39;的未处理异常 - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll asp.net-mvc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM