Why are Redirect Results not allowed in Child Actions in Asp.net MVC 2

Solution 1:

The limitation exists because MVC has already started rendering a view to the client. The effect of redirecting from this point is undefined. It could work perfectly, it could continue rendering the original view without redirecting, it could throw a different exception, etc.

Since the result of performing this action is undefined, the framework blocks it. In practice, RenderAction should never be used to render anything other than a view (or view-like content) for similar reasons.

In your particular case, the outer action should redirect. If you're just going to end up redirecting from within the view anyway without showing anything to the user, then there was really no purpose to going through the view in the first place, as the outer action could have delegated the work appropriately on its own.

Solution 2:

Try to use something like this in Child Action:

ControllerContext.HttpContext.Response.Redirect(ControllerContext.HttpContext.Request.Url.ToString());

Solution 3:

My solution.

Action method:

return View("Redirect", model);

View:

<script type="text/javascript" language="javascript">
    document.location = '<%: Url.Action("Index", "Album", new { id = Model.Id }) %>';</script>