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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:49:24+00:00 2026-05-25T06:49:24+00:00

My MVC application consists of Admin and normal users. Admin users can register as

  • 0

My MVC application consists of Admin and normal users. Admin users can register as different customers using the system, and they can add their respective users to the system.

The controllers already have Authorize filters on certain controllers to prevent unauthorised access to certain pages/json.

However, say I have an admin user logged in, what prevents them from inspecting the Json posts/gets in the JavaScript and manually calling a ‘get’ with the Id of the specific data to be viewed? e.g. /Users/1

Testing my application, I could post an AJAX get, to retrieve the details of another user in the system which was not under the management of the current authenticated user.

I could write access check methods whenever a service method is called to see if the user can view the data. Are they any good ways of solving this problem without littering the application with access check methods all over the place?

e.g. Current Implementation

public class PeopleController : ApplicationController
{
    public ActionResult GetMemberDetails(int memberId)
    {            
        var member = _peopleService.GetMemberById(memberId);
        return Json(member, JsonRequestBehavior.AllowGet);
    }
}

public class PeopleService : IPeopleService
{
    public MemberModel GetMemberById(int memberId)
    {
        // Void function which throws Unauthorised exception
        MemberAccessCheck(memberId);

        var member = Mapper.Map<Member, MemberModel>(_memberRepository.GetById(memberId));
        return member;
    }
}

The MemberAccessCheck function is called lots of times in my service.

  • 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-25T06:49:24+00:00Added an answer on May 25, 2026 at 6:49 am

    You’re going to have to write these checks inside your controller or service. I dont think you should use a custom attributefilter for this behaviour because you are basically filtering data from a service layer standpoint. Nor is Auhorize attribute suitable for this featire also.

    What I suggest is that you have a service method that accepts the current userId from the controller (take the User.Identity) and send it to the service to get the list of user’s or single user that they can view/modify. So its not necessarily littering with access checks, but it would be how your service operates (a business rule).

    Eg of Service Method:

    User GetAdminUser(int userId, int adminId);
    List<User> GetAdminUsers(int adminId);
    

    Or, just overload your previous service

    User GetUser(int userId);
    User GetUser(int userId, int adminId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Linq to SQL within an ASP.NET MVC application. The model consists of
In my asp.net MVC application I am using in place editors to allow users
So imagine I'm building a Multi User Dungeon system using a MVC web application.
I'm building an MVC application that consists of entities that can be referenced by
In an ASP.NET MVC application, I'm making logic for Admin to accept or reject
In my ASP MVC application I'm using standard SQL (rather that Linq to SQL
I have a MVC application that I am now trying to add authentication and
I have a spring MVC application using JSP as my view technologies with Jquery
In our ASP.NET MVC application, we automatically redirect users to a log-on page via
Inside of my MVC application, I have a sub-folder named Admin that was Converted

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.