2
RedirectToRouteResult
不會重定向到指定的控制器 - 操作對。ASP.NET MVC 3 RedirectToRouteResult
public class CustAuthorizeAttribute : AuthorizeAttribute, IAuthorizationFilter
{
...
public override void OnAuthorization(AuthorizationContext filterContext)
{
base.OnAuthorization(filterContext);
...
if (...) {
var routeDictionary = new RouteValueDictionary { { "action", "Forbidden" }, { "controller", "Error" } };
filterContext.Result = new RedirectToRouteResult(routeDictionary);
}
}
}
請幫忙。
它的路線哪裏來?你有什麼特別的路線設置?你的路由規則是什麼樣的? – dreza