asp.net mvc ActionFilterAttribute-重定向到“;控制器/动作/参数”;
本文关键字:控制器 参数 动作 mvc net ActionFilterAttribute- 重定向 asp | 更新日期: 2023-09-27 18:28:13
我之前的问题已经解决了asp.net mvc validate[HttpPost]ActionResult()
对!。现在,我需要从ActionFilterAttribute Helper类中的OnActionExecuting()方法重定向到"controller/action/parameter"。在线
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!
试试这个:
filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary {
{ "action", "login" },
{ "controller", "persons" },
{ "someQuerystring", "someValue" }
}
);