Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 475385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:22:59+00:00 2026-05-13T00:22:59+00:00

How do I set my Authorize(Roles=blah) token to redirect to a You’re not authorized

  • 0

How do I set my Authorize(Roles=”blah”) token to redirect to a “You’re not authorized to do this” when a user is already logged in but isn’t in the correct role? Currently it redirects to the login page which isn’t what we’re after. We feel that it’s confusing for the user to be redirected to this page as they’re already logged in. In the event however they’re not logged in, it should redirect to the login page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:22:59+00:00Added an answer on May 13, 2026 at 12:22 am

    The way AuthorizeAttribute is designed is that it will first look if the user is authenticated and then look if he is in role. If any of these conditions aren’t satisfied it will simply return return a HttpUnauthorizedResult which in turn will set the response code to 401. To achieve what you want you will need to implement your own IAuthorizationFiler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I set this above my Controller: [Authorize(Roles=Administrator)] The problem is whether they are
I've set this in my AppController.php $this->Auth->authorize = array( 'Actions' => array( 'actionPath' =>
I learned I can redirect the user to a different page like this http://www.asp.net/web-forms/tutorials/security/membership/user-based-authorization-vb
set(TestProject_additional_libs optimized foobar.lib debug foobard.lib } especially what is optimized/debug mean here? Is this
set batVar_Parameters=/Developer /Test=0 if not '%batVar_Iteration%' equ '-1' ( set batVar_Parameters=%batVar_Parameters% /Iteration=%batVar_Iteration% ) if
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
I am currently hard coding the authorized roles in the filter in my MVC
I'm creating a custom role provider and I set a Authorize attribute specifying a
I have a simple Ability.rb set up listed below: if user.role? :super_admin can :manage,
How can I set an ability to allow a user to only edit their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.