Error executing child request for handler in view

后端 未结 12 916
臣服心动
臣服心动 2020-12-09 02:30

I have an MVC 4 view where I render the following actions

@{
    Html.RenderAction(\"Index\", \"Logo\");
    Html.RenderAction(\"Index\", \"MainMenu\");
}


        
相关标签:
12条回答
  • 2020-12-09 03:03

    I had this problem, It could happen because render engine can't find any view (corresponding to the name that is given in acton) I'd given wrong name of view (I mistakenly had given action name instead of view name) when I return view name and view model using PartialView() method, I corrected my view name and it worked fine

    0 讨论(0)
  • 2020-12-09 03:07

    This happened to me, because I was calling the view from different areas.

    The view I wanted to call was not within an area, so when calling it from outside of all areas a call like

    @Html.RenderAction("Index", "Logo");

    would work without problems.

    But when I wanted that same view called from another view that was inside an area, I would have to add some additional information to the call to make it explicit:

    @Html.RenderAction("Index", "Logo", new { area = "" });

    0 讨论(0)
  • 2020-12-09 03:08

    I had the same error. It began when I changed an action to another controller, so when running the program couldn't find the view in the folder. So if you move an action to another controller, also move the view to the respective folder's controller.

    0 讨论(0)
  • 2020-12-09 03:12

    I had exactly the same problem, and because I was using attribute routing, the inner exception error message was:

    No matching action was found on controller ''. 
    This can happen when a controller uses RouteAttribute for routing, 
    but no action on that controller matches the request.
    

    Remove the [HttpGet] attributes from action methods called by Html.Action() and it works. Nothing to do with routing.

    0 讨论(0)
  • 2020-12-09 03:13

    In my case, I added the following code into Global.asax.cs:

    protected void Application_Error(object sender, EventArgs e)
    {
        var ex = Server.GetLastError();
        ...
    }
    

    Then I added a break point there and see the ex's InnerException is the SQL DB Connection error. So I replaced my Web.config file with my local development one with the correct connection string, and the problem is gone.

    0 讨论(0)
  • 2020-12-09 03:14

    I got this error, but my problem was diferent. To see what is the error about, involve the line you get the error inside a try catch code, like this:

     try 
        {           
             @Html.RenderAction("Index", "Logo", new {id = Model.id});
        }
        catch (Exception e)
        {
            throw;
        }    
    

    Execute it with a break point at throw line and check the inner exception of the 'e'. My problem was that I'd changed the parameter name on my Controller and forgot to change it on my View.

    It's easier to get the error using try catch.

    0 讨论(0)
提交回复
热议问题