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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:30:54+00:00 2026-06-18T17:30:54+00:00

I have a regular MVC app with a standard account controller. I’ve added couple

  • 0

I have a regular MVC app with a standard account controller. I’ve added couple fields to UserProfile class, so now it looks like this:

 public class UserProfile
    {
        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int UserId { get; set; }
        public string UserName { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Email { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
        public string FullName { get { return FirstName + " " + LastName; } }
        public int GroupId { get; set; }
        [ForeignKey("GroupId")]
        public ICollection<Group> Groups { get; set; }
        }   

So, basically saying that User can be assigned to multiple groups. (And also in Group class I say that Group can contain multiple users, obviously).

Now, each user must be in a specific role. (Admin, Teacher, Student etc.)

I’ve added roles support by following a tutorial online like this:

<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
      <providers>
        <clear/>
        <add name="SimpleRoleProvider" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
      </providers>
    </roleManager>
    <membership defaultProvider="SimpleMembershipProvider">
      <providers>
        <clear/>
        <add name="SimpleMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData" />
      </providers>
    </membership>   

Now I want to filter all of the users by RoleName. But I do not have any way to do that.
IE. something like this. Users.Where(x=>x.RoleName=="Admin").Select(x=>x.FullName)
(Users is a property of a Group class of type ICollection<Users>). How do I get to the roles without having a class for the roles?

  • 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-18T17:30:56+00:00Added an answer on June 18, 2026 at 5:30 pm

    The asp.net membership has a static Roles class with a GetUsersInRole method, also the CurrentUser in HttpContext can tell you the roles the active user is in.

    http://msdn.microsoft.com/en-us/library/system.web.security.roles.getusersinrole.aspx

    http://msdn.microsoft.com/en-us/library/system.web.security.membershipuser.aspx

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

Sidebar

Related Questions

I have an MVC app that is working fine, but I now want to
I am learning Spring 3.x MVC. I now have a regular web page setup
please help me with asp.net MVC 2 application. I have class: public class Account
I have an MVC application which is my marketing website, and two other regular
I have an application written in MVC that uses your regular .Net Forms Authentication.
I have been using the following regular expression in ASP.NET and Javascript: [a-zA-ZöäüÖÄÜß0-9]{1}[a-zA-ZöäüÖÄÜß0-9_.\-]{2,14}[a-zA-ZöäüÖÄÜß0-9.!]{1} Now,
Possible Duplicate: ASP.NET MVC 3 controller action for partial view I have a page
i have a regular html Grid and i am binding my asp.net mvc view
I have added a regular expression from a site to verify user name and
I have a simple Edit action in ASP.NET MVC that looks like 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.