"Child actions are not allowed to perform redirect actions"

Solution 1:

This happened to me because I had [RequireHttps] on the Controller, and a child action was called from a different controller. The RequireHttps attribute caused the redirect

Solution 2:

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.

Solution 3:

Instead of @Html use @Url.

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

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

Solution 4:

I had same situation like Doug described above

My solution: 1)Created custom Controller Factory. It's need for getting ControllerContext in my custom https attribute.

public class CustomControllerFactory : DefaultControllerFactory
    {
        public override IController CreateController(RequestContext requestContext, string controllerName)
        {
            var controller = base.CreateController(requestContext, controllerName);
            HttpContext.Current.Items["controllerInstance"] = controller;
            return controller;
        }
    }
}

2)In Application_Start function from Global.asax file wrote next:

ControllerBuilder.Current.SetControllerFactory(new CustomControllerFactory());

3)Defined custom https attribute:

public class CustomRequireHttpsAttribute : System.Web.Mvc.RequireHttpsAttribute
    {
        public bool RequireSecure = false;

        public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
        {

            if (RequireSecure && !((Controller)HttpContext.Current.Items["controllerInstance"]).ControllerContext.IsChildAction)
            {
                base.OnAuthorization(filterContext);
            }
        }        
    } 

4)Using new attribute for definition of account controller: [CustomRequireHttps]