asp.net mvc ActionFilterAttribute - 重定向到“controller / action / parameter”

时间:2014-10-29 14:55:36

标签: c# asp.net-mvc redirecttoaction

我以前的问题已解决asp.net mvc validate [HttpPost] ActionResult()

右!现在我需要重定向到" controller / action / parameter"来自ActionFilterAttribute Helper Class中的OnActionExecuting()方法。在行

public class HelperSeguridad : ActionFilterAttribute
{
  public override void OnActionExecuting(ActionExecutingContext filterContext)
  {
   .
   . 
   .    
    if (permission != “”)
          {
            redirect "HERE"
          }
  }
}

控制器代码:

public class PaisController : Controller
{
.
.

  public ActionResult Error(Exception ex)
  {
     ViewBag.error = ex;
     return View();
  }

}

THKS!

1 个答案:

答案 0 :(得分:0)

试试这个:

filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary {
    { "action", "login" },
    { "controller", "persons" },
    { "someQuerystring", "someValue" }
}
);