filters.Add(new AuthorizeAttribute()); filters.Add(new HandleErrorAttribute()); } 如果需要过滤角色才能访问还需要添加 public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new AuthorizeAttribute());
filters.Add(new InitializeSimpleMembershipAttribute()); filters.Add(new HandleErrorAttribute()); } 只有角色为admin才能访问store [Authorize(Roles="admin")] public class StoreController : Controller
转载于:https://my.oschina.net/xuyuchends/blog/852153