Why does AuthorizeAttribute redirect to the login page for authentication and authorization failures?
问题 In ASP.NET MVC, you can mark up a controller method with AuthorizeAttribute , like this: [Authorize(Roles = \"CanDeleteTags\")] public void Delete(string tagName) { // ... } This means that, if the currently logged-in user is not in the \"CanDeleteTags\" role, the controller method will never be called. Unfortunately, for failures, AuthorizeAttribute returns HttpUnauthorizedResult , which always returns HTTP status code 401. This causes a redirection to the login page. If the user isn\'t