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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:28:46+00:00 2026-05-26T19:28:46+00:00

I have a simple ASP.NET MVC 3 application. I have the database I designed

  • 0

I have a simple ASP.NET MVC 3 application. I have the database I designed for the application, which corresponds to a domain model (in an App.Domain assembly).
I auto-generated the Application Services Membership tables and added them to the application database. Membership creation is working fine.
I created a ‘Permission’ table which has a composite PK made up of UserId (from the auto-generated aspnet_Users table) and ContentId (from the Content table holding the application content).
The idea is to allow users to allocate permissions to other users for the content they create.
My plan is to then place logic in the Controllers that goes something like:
Collapse | Copy Code

Guid currentUser = (Guid)Membership.GetUser().ProviderUserKey;
int[] accessible = (from p in context.Permissions
                         where p.UserId == currentUser
                         select p.ContentId).toArray();

Then to get the content for the current user, something like this:
Collapse | Copy Code

IEnumerable<content> content = context.Content
            .Where(x => x.PublicAccess < 3 
            || accessible.Contains(x.ContentId));</content>

If I have made any sense, can anyone tell me if this is a normal way to handle user defined permissions.
Also, this code doesn’t work because it won’t cast the linq to an int[]. Any help with that?

  • 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-26T19:28:46+00:00Added an answer on May 26, 2026 at 7:28 pm

    Typically permissions are handled by the role subystem. You do something like this:

    if (User.IsInRole("RoleName")) {
       DoWhateverTheUserIsAllowedToDo();
    }
    

    You can combine this with dynamically assigned content permissions by looking up what roles or users are assigned to the content, and checking if the user is in that role, or if the users is specifically allowed.

    Role based permission scales better than assigning users to specific pages. As the number of pages grow, assigning users to pages becomes a nightmare. So you typically assign roles to pages, then assign users to roles.

    Your code seems to want to do a lot of work, returning lots of different content items. Typically, you know what item you want to control access to. So you might do something like:

    var roles = Roles.GetRolesForUser()
    var content = from p in context.Permissions where p.ContentID == contentID 
                          && roles.Any(x => p.Roles.Contains(x)) select p;
    

    But, there are so many ways to do this, you will have decide what works best for you.

    I don’t understand your last bit about not casting to an int[]. I assume .toArray() is a typo, it should be .ToArray(). And if ContentID is an int, .ToArray should create an int[].

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

Sidebar

Related Questions

I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have an ASP.NET MVC application which is pretty simple so far, but I
I have a simple ASP.NET MVC web application that uses NHibernate with FluentNHibernate's auto
Let's say I have a simple ASP.NET MVC blog application and I want to
Hi I am developing a simple application based upon ASP.NET MVC. I have altered
I have an ajax form in asp.net mvc which is as simple as this:
I have written a simple ASP.NET MVC 2 application that stores data and can
I have a pretty simple ASP.NET MVC Site Application. (MVC 1.0) I have NO
I have an Asp.Net MVC 3 application with a database Consultants, accessed by EF.
I have an ASP.NET MVC web application which is hosted by an external provider,

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.