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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:09:16+00:00 2026-05-29T17:09:16+00:00

Im writing this webapp and want to authorize controllers by mixed conditions. For example:

  • 0

Im writing this webapp and want to authorize controllers by mixed conditions. For example:

I want to allow acces if user is in role “Administrator” or its username is “programad”, like this:

[Authorize(Roles = "Administrator", Users = "programad")]

I want that, because when I first register myself on the application (for testing, dev process etc) I am not Administrator yet. I want to get the first acces by my username so then I can put myself on the Administrator role.

I put that on the controller level but doesn’t seem to work, it asks me to logon again and it denies me access even when I enter my credentials.

How can I authorize by my username and/or by my role?

  • 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-29T17:09:19+00:00Added an answer on May 29, 2026 at 5:09 pm

    This is because the AuthorizeAttribute is saying a user must be in the “Administrator” role AND named “programad”. The easiest workaround would be to create another role, place the user “programad” in it and then Change your AuthorizeAttribute to

    [Authorize(Roles = "Administrator, NewRole")]

    where NewRole is whatever you name the new role to contain user “programad”.

    If you really need to change the AuthorizeAttribute to behave with the role OR user, you will need to create a new class that derives from AuthorizeAttribute and overrides the AuthorizeCore method filling in your authorization logic.

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

Sidebar

Related Questions

I am writing a web app which will allow the user to specify a
I'm writing a photo gallery webapp for a friend's wedding and they want a
I'm writing this question in the spirit of answering your own questions, since I
I'm writing this question from the standpoint of an ASP.NET application. However I realize
I am writing this java program to find all the prime numbers up to
I'm writing this question with reference to this one which I wrote yesterday. After
Unfortunately I am not writing this question from my Developing PC so I might
I am writing this comment class: class Comment { public $id; public $post_id; public
I'm writing this script to rotate a background Image every 3 seconds but it
i'm writing this: echo foo; echo \n; echo bar; and bar is not written

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.