I had same situation like Doug described above
Giải pháp của tôi: 1) Tạo nhà máy điều khiển tùy chỉnh. Nó cần cho việc nhận ControllerContext trong thuộc tính https tùy chỉnh của tôi.
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) Trong Application_Start hàm từ tập tin Global.asax viết tiếp theo:
ControllerBuilder.Current.SetControllerFactory(new CustomControllerFactory());
3) https tùy chỉnh Defined thuộc tính:
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) Sử dụng thuộc tính mới cho định nghĩa về tài khoản bộ điều khiển: [CustomRequireHttps]
Nguồn
2014-01-20 16:07:13
Bạn có thể tìm câu hỏi này http://stackoverflow.com/questions/2056421/why-are-redirect-results-not -cho phép-trong-con-hành động-trong-asp-net-mvc-2 – Tassadaque
Bao nhiêu lần bạn định hỏi điều này ngày hôm nay? Có thể trùng lặp của [Lỗi thực hiện yêu cầu con cho trình xử lý] (http://stackoverflow.com/questions/8924177/error-executing-child-request-for-handler) –