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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:31:29+00:00 2026-06-10T05:31:29+00:00

This allows frankl to access but blocks the admins. What have I done wrong?

  • 0

This allows “frankl” to access but blocks the admins. What have I done wrong?

 [Authorize(Order=1,Roles = "Admin",Users="frankl")]
public class AuthorizeBaseController_Admins_frank : Controller
{

}

It is probably simple but I don’t see any examples that combine the two and the “Allowmultiple” property generates an error when I try to add it.

Thanks,
Chris

  • 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-06-10T05:31:31+00:00Added an answer on June 10, 2026 at 5:31 am

    Roles and Users should be used exclusively. If you want to combine them you could write a custom authorize attribute:

    public class MyAuthoirizeAttribute : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            var user = httpContext.User;
            if (!user.Identity.IsAuthenticated)
            {
                return false;
            }
            var usersSplit = SplitString(Users);
            var rolesSplit = SplitString(Roles);
    
            return
                (usersSplit.Length > 0 && usersSplit.Contains(user.Identity.Name, StringComparer.OrdinalIgnoreCase)) ||
                (rolesSplit.Length > 0 && rolesSplit.Any(user.IsInRole));
        }
    
        private string[] SplitString(string original)
        {
            if (string.IsNullOrEmpty(original))
            {
                return new string[0];
            }
            return (from piece in original.Split(',')
                    let trimmed = piece.Trim()
                    where !string.IsNullOrEmpty(trimmed)
                    select trimmed).ToArray();
        }
    }
    

    and then:

    [MyAuthorize(Order = 1, Roles = "Admin", Users="frankl")]
    public class AuthorizeBaseController_Admins_frank : Controller
    {
        ...    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Yesod application (but question is more general than this) that allows
I have a system that builds up reports on incedents. This allows the users
In my iPhone app, I have a appSettings.plist. This allows me, but also others
I have read about the Opt-Out plugin for Google Analytics. This allows end-users to
I am trying to create a search page, this allows the admin to search
In my masterpage, I have the following in the header. This allows me to
I have a service that use the tcp binding and this services allows to
C and many other languages have a conditional (AKA ternary) operator. This allows you
I have a Constraint on a table with IGNORE_DUP_KEY. This allows bulk inserts to
I have a UIPicker with 3 components containing numeric values, this allows the user

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.