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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:00:51+00:00 2026-06-13T02:00:51+00:00

I have an ASP.NET MVC4 site with custom user/role provider. Entity Framework works with

  • 0

I have an ASP.NET MVC4 site with custom user/role provider. Entity Framework works with the user and role entities at the bottom level. Now I am introducing a concept of RolePermissions. Each role has an asscocialted list of permissions that allow users in this role to perform certain actions within the system, like deleting comments for example.

In my custom-build admin panel I want to list all the actions of a controllers and have an ability to allow or disallow the call to some action based on the presenace of a permission in the curent user’s role.

Questions are:

  1. Is it possible?
  2. How do I list a set of actions in the controller.
  3. How do I assign or cancel an association between action and a role permission.

Possible starategy:

I introduce a global custom filter that is applied to all of the controllers and actions, that checks my database to see If I have a logical association. This way a checking code is ran every time the user makes a call to an action. Still how do I list controllers and actions (via reflection perhaps?)

  • 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-13T02:00:52+00:00Added an answer on June 13, 2026 at 2:00 am

    Still how do I list controllers and actions (via reflection perhaps?)

    Yes, reflection is one way to do it. Here’s an example of how to get a list of all controller types:

    public IEnumerable<Type> GetControllers()
    {
        IEnumerable<Type> typesSoFar = Type.EmptyTypes;
        var assemblies = BuildManager.GetReferencedAssemblies();
        foreach (Assembly assembly in assemblies)
        {
            Type[] typesInAsm;
            try
            {
                typesInAsm = assembly.GetTypes();
            }
            catch (ReflectionTypeLoadException ex)
            {
                typesInAsm = ex.Types;
            }
            typesSoFar = typesSoFar.Concat(typesInAsm);
        }
        return typesSoFar.Where(type => 
            type != null && 
            type.IsPublic && 
            type.IsClass && 
            !type.IsAbstract && 
            typeof(IController).IsAssignableFrom(type)
        );
    }
    

    and then you could get a list of ActionDescriptor for each controller type:

    foreach (var controller in GetControllers())
    {
        ActionDescriptor[] actions = new ReflectedControllerDescriptor(controller).GetCanonicalActions();
        foreach (var action in actions)
        {
            // here you know everything about the action
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an asp.net mvc4 site using entity framework 5 with codefirst and
I have an ASP.NET MVC4 site with mobile content. When I deploy this on
I have integrated ASP.NET MVC 4 into existing asp.net web site. Both works fine
I have a web site built using ASP.NET MVC4 that I can publish fine
I have a custom Principal/Identity for my ASP.NET MVC4 web app. I have also
I have a ASP.NET MVC 4 project - CodeFirst with Entity Framework - that
I have an ASP.NET MVC4 app which uses DotNetOpenAuth 4.0.1 to authenticate users with
I have a simple asp.net MVC4 / EF 4.1 project created with VS 2011,
I have been writing an application using ASP.Net MVC4, where the majority of the
In ASP.NET MVC 4 Beta, I have an entity with this property: [DisplayFormat(DataFormatString =

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.