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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:24:26+00:00 2026-05-23T14:24:26+00:00

I am designing an MVC 3 application where multiple tenants reside in a single

  • 0

I am designing an MVC 3 application where multiple tenants reside in a single database.

What is the best way to prevent users from editing/viewing other tenants data in MVC? (i.e. someone could type in ‘/People/Edit/1’ and edit the person with Id of 1- regardless of wether they are part of the tenants data or not).

I know I can override ‘OnActionExecuting(ActionExecutingContext filterContext)’ for each controller- but it sounds crazy to have to handle each action seperately, get the ID or OBJECT depending on if its a POST or GET and then check if the operation is allowed.

Any better ideas?

Also, I do not want to go down the route of creating a different database or schema for each tenant.

Thanks in advance.

  • 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-23T14:24:27+00:00Added an answer on May 23, 2026 at 2:24 pm

    Original answer

    To solve the problem quickly use guids instead of a auto-increasing integer. However this is just delaying the problem.

    One of the things you can do is to role your own authorize attribuut http://msdn.microsoft.com/en-us/library/system.web.mvc.authorizeattribute.aspx Or you can chose to create a global actionfilter. http://www.asp.net/mvc/tutorials/understanding-action-filters-cs

    Addition information on how you could do it based on request in comment

    public class MySuperFilter : ActionFilterAttribute
        {
            //Called by the MVC framework before the action method executes.
            public override void OnActionExecuting(ActionExecutingContext filterContext)
            {
                String user = filterContext.HttpContext.User.Identity.Name;
                int id = int.Parse(filterContext.RouteData.GetRequiredString("Id"));
                if (!IsValidUser(user,id))
                {
                    filterContext.Result = new RedirectToRouteResult(
                            new RouteValueDictionary {{ "Controller", "YourController" },
                                          { "Action", "YourAction" } });
    
    
                }
    
                base.OnActionExecuting(filterContext);
            }
    
            private bool IsValidUser(string user,int id)
            {
                //Check if the user has acces to the page
                return true;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am designing a multi tenants web portal application using MVC. Tenants will be
I am designing a database for an ASP.NET MVC application. I'm an expert in
I'm in the process of designing my ASP.NET MVC application and I ran across
I am designing a web application using the ASP.net MVC framework. I would like
I am designing a product management system. I am wondering the best way to
Rather than use a full-blown PHP MVC, I'm designing one that will best-fit my
I'm designing forms in my ASP.NET MVC application that will receive objects. Here's what
I have an Asp.Net MVC 3 application with a database Consultants, accessed by EF.
Designing a web application with ASP.NET MVC I asked myself how can I also
I was wondering how to design this best.. On my ASP.NET MVC application I

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.