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 296077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:30:56+00:00 2026-05-12T06:30:56+00:00

is there any generic way to get the role which is required for some

  • 0

is there any generic way to get the role which is required for some particular action?

In Detail my problem is, that I have e.g. 2 roles “User” and “Admin” and an action with the following:

[Authorize(Roles = “Admin”)]
public class AdministrationController…

If the user is not logged in, he gets the login screen. That’s ok. When a user with the role “Admin” logs in, all works fine. But if a user with the role “user” logs in, he will be continiously displayed the login screen, besides he has succesfully logged in, but of course not the required role.

So it would be good if the login display could display to him a hint, telling that he is already logged in, but he has not the required rights to see this page. And additionally it may display the required role(s).

Thanks,
Michael

  • 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-12T06:30:57+00:00Added an answer on May 12, 2026 at 6:30 am

    I think this mostly stems from the default AuthorizeAttribute design of showing the login page if any part of Authorization fails.

    You may want to create a new class that inherits from AuthorizeAttribute. You can then override the default behaviour and show a different page. See
    http://schotime.net/blog/index.php/2009/02/17/custom-authorization-with-aspnet-mvc/#comment-159 for a great example of this.

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

Sidebar

Related Questions

Hi is there any way in Java to get staticly generic class type I
Is there any way to get a List<string> which contains all 'usings' within a
Is there any shorthand way of defining and using generic definitions without having to
Is there any way to determine if an object is a generic list? I'm
Is there any feasible way of using generics to create a Math library that
Are there any more generic tools that can compile or basically merge multiple PHP
Is there any (technical) reason that C# requires all generic type parameters to be
Is there a generic way I can get a post-build event to copy the
Is there any reason for the use of 'T' in generics? Is it some
Is there any way to check whether a file is locked without using a

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.