3
votes

I have a method in my Home Controller that returns a partial view, but when I run my application I get the error.

Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.

The Method in my controller gets the model and returns the partial view.

public PartialViewResult _GetToDo()
        {
            using (KnightOwlContext db = new KnightOwlContext())
            {
                var todoList = new List<ViewModels.ToDo>();
                DashboardHelper dashHelper = new DashboardHelper(db);

                var results = dashHelper.GetToDoList(StaffId);

                foreach(var r in results)
                {
                    todoList.Add(new ViewModels.ToDo()
                    {
                        ToDoId = r.ToDoId,
                        Complete = r.Complete,
                        Date = r.Date,
                        Priority = GetPriority(r.Priority),
                        StaffId = r.StaffId,
                        Text = r.Text
                    });
                }

                return PartialView("_ToDo", todoList);
            }
        }

And I call this method in my View:

@Html.Action("_GetToDo", "Home")

The method is in my 'Home Controller' and the Partial View is called from Views > Home > Index

So far I've tried Html.Partial and Html.RenderPartial and neither of those work either with a different error message. I'm completely at a loss as to how to return the partial view, what is it I'm doing wrong?

1
It is possibly because you have an error in the _ToDo.cshtml view. Put a break point in the partial view and step through it. Another common cause is that you partial view is generating an infinite loop.user3559349
There was an error inside the view - it couldn't find the physical view in the file sytem. Thanks - if you want to pop that in as the answer I'll mark it off if you like?Web Develop Wolf

1 Answers

0
votes

During _ToDo view creation tick the checkbox Create as Partal View. If you create your partial view referencing your layout page, then you will get in an infinite loop, executing your layout page over and over.