我有这个ActionFilter
public class AppOfflineFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.ActionDescriptor.ActionName != "AppOffLine" && filterContext.HttpContext.Request.UserHostName != "127.0.0.1") { filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary( new { action = "AppOffLine",Controller = "Home" })); } } }
它起始页面不在一个区域内,它不适用于某个区域,因为它将重定向到/ Area / Home / Appoffline而不是/ Home / AppOffline
可以固定吗?
解决方法
尝试将区域路线令牌分配给一个空字符串:
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { action = "AppOffLine",controller = "Home",area = "" }));