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

  • Home
  • SEARCH
  • 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 8542245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:01:03+00:00 2026-06-11T12:01:03+00:00

I’m looking to solve a problem I have with implementing role-based authorization of a

  • 0

I’m looking to solve a problem I have with implementing role-based authorization of a project I’m working on. The project is in ASP.NET MVC 3.

The application authenticates users and these users have certain system-wide roles associated with them. This part I am fine with.

The problem arises with the concept of Projects, Teams and Team Roles within the application. For each Project that a manager creates, they can create a Team. This Team consists of other system users, who will assume Roles within the Team, but just for that Project.

So a user may have Role A in one project and may have Role B in another and Role C in another.

The biggest problem I face, is that at the moment the Action Method might have the signature (example code, not real code):

[Authorize(Roles = "SomeExampleSystemRole")]
public ActionResult DoSomeTask(Guid id)
{
    // id is the project id.
}

In which case even if I coded up a custom attribute, I wouldn’t know which Project (and subsequently which Team) the user was calling this task in relation to, not until I was inside the method and could access the ‘id’ argument.

So far I have thought of creating another class, but this still would have to sit within the Action Method, so that it knows the current Project id:

[Authorize(Roles = "SomeExampleSystemRole")]
public ActionResult DoSomeTask(Guid id)
{
    // some code to get the current user identity.

    // id is the project id.
    TeamAuthorization auth = new TeamAuthorization(userIdentity, id);

    bool authPassed = auth.DoesUserHaveTeamRole("RoleC");
}

However if the user doesn’t have the system role that’s required, they’ll never get to the secondary authorization code inside the Action Method.

Does anyone have any ideas on how this sort of transient role problem can be elegantly solved? In addition, we’re moving away from a heavily ‘Session’ based implementation and don’t envisage a ‘Session’ based solution as being manageable.

I’m currently looking at whether the Team Roles are different from the System Roles, if so then the solution above may work in part.

Would it be possible using Attributes to be able to read the ‘id’ in the method’s parameters?

Any suggestions would be greatly appreciated. Many thanks.

Edit:

I’ve had an extra thought that it might be best to simply apply a global Authorize attribute to ensure that users are authenticated, then role-up the system roles into the TeamAuthorization class, so that at least system and team roles can be joined into one super-set. This also might work in instances where the project or team id isn’t passed into the method (or as obvious).

  • 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-11T12:01:04+00:00Added an answer on June 11, 2026 at 12:01 pm

    In the Authorize attribute, you get the HttpContext. You could use something like this:

    var routeData = new RouteCollection();
    
    MvcApplication.RegisterRoutes(routeData);
    
    var route = routeData.GetRouteData(httpContext);
    

    MvcApplication is your global application class. This will bind up the routes, then parse the request to give you the route that has been called. You can then ask it for the Id parameter to perform the extra authorization on that.

    Si

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.