Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Child actions are not allowed to perform redirect actions"

I have this error:

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

with inner exception:

Child actions are not allowed to perform redirect actions.

Any idea why this happening?

Incidentally, the error is happening on this line:

@Html.Action("Menu", "Navigation")

The Menu Action in the Navigation Controller looks like this:

public ActionResult Menu()
{
    return PartialView();
}
like image 575
Sachin Kainth Avatar asked Jan 19 '12 10:01

Sachin Kainth


Video Answer


2 Answers

Instead of @Html use @Url.

Before: @Html.Action("Menu", "Navigation")

After: @Url.Action("Menu", "Navigation")

like image 64
Dumisani Avatar answered Oct 13 '22 07:10

Dumisani


This is not allowed because MVC has already started Rendering the View to the browser (client). So the MVC Frameworks blocks this, because the client already receives data (html). As long as the rendering is in progress you not able to redirect in your child view.

You can return RedirectToAction instead.

like image 21
dknaack Avatar answered Oct 13 '22 09:10

dknaack