0

I am trying to return a page within another when an id is passed on to a controller. But I get this error:

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

Views\Error_Summaries\Details.cshtml

  @{Html.RenderAction("FindAllDetails", new { bolnumber = Model.BOL });}

Error_SummariesController.cs

public ActionResult FindRelatedBols(string bolnumber)
{
    if (bolnumber == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    Error_Summaries error_Summaries = db.Error_Summaries.SingleOrDefault(r => r.BOL == bolnumber);
    if (error_Summaries == null)
    {
        return HttpNotFound();
    }
    return View("Views/Error_Details/Details");
}
null
  • 713
  • 2
  • 8
  • 30
  • 1
    That means, your code is crashing when trying to render the result of that action method. Check the Inner exception and it will tell you what the error is. – Shyju Dec 04 '17 at 16:32
  • 1
    Also you probably want `return View("~/Views/Error_Details/Details.cshtml");` – Shyju Dec 04 '17 at 16:32
  • 1
    If you are trying to render a partial view, you should use `PartialView` method: `return PartialView("/Error_Details/Details");` – Phi Dec 04 '17 at 16:43
  • All three comments helped so I don't know if somebody wants to make it an answer. I have one more question here - https://stackoverflow.com/questions/47638357/error-when-converting-list-to-ienumberable – null Dec 04 '17 at 17:02
  • 1
    You can self answer since you are the only one know what the exact problem was. – Shyju Dec 04 '17 at 17:03

1 Answers1

0

When checking the inner exception it showed that it was looking at the wrong action name. I had specified FindAllDetails instead FindRelatedBols. Also, the return path was wrong. And finally, I wasn't using the right Method name.

public ActionResult FindRelatedBols(string bolnumber)
{
    if (bolnumber == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }
    //var test = 
    //var qrytest = db.Error_Details.Where(r => r.BOL == bolnumber);
    //var details = qrytest.ToList();
    var details = db.Error_Details.Where(r => r.BOL == bolnumber).ToList();
    if (details == null)
    {
        return HttpNotFound();
    }
    return PartialView("~/Views/Error_Details/Index.cshtml", details);
}
null
  • 713
  • 2
  • 8
  • 30