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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:32:39+00:00 2026-05-22T19:32:39+00:00

I have 3 different types of users (with different roles) interacting on my web

  • 0

I have 3 different types of users (with different roles) interacting on my web application, they all perform some task – some can be exactly the same e.g. create a quote others can be unique to that specific user e.g. sign off quote.

For more clarity 3 types of users: Client, Supplier, Customer.

Client or Customer can create a quote, however only the Customer can sign off a quote.

How do I ensure my application allows clients to access client speficic controllers and suppliers to access supplier specific controllers or areas. Via Custom Attributes? Do I store the type of user inside a cookie? Is this safe? or Session state? As soon as someone logs onto the system I send back a LoggedOnDTO object on which I store Username, UserID, and type of user….

NOTE: I went away from asp.net build in way of creating users, I have my own custom tables with my custom mechanism for logging into the system. I have a registered Model Bindiner that looks for the prefix and I send in a strongly typed object to each action…

Sample code:

[HttpGet]
public ActionResult AddComment(int quoteid, ClientUserDTO loggedonclientuser)
{

}

[HttpGet]
public ActionResult AddCommentSupplier(int quoteid, Supplier loggedonsuppluser)
{

}

EDIT: This method for some reason seems so much simpler… Is there something wrong with it? Any possible security issues? Threading?

My session controller is:

if (_authService.isValidUser(model))
{
   var data = _authService.GetAuthenticationCookieDetails(model);
   AuthenticateCookie.AddDetailsToCookie(data);
   return Redirect(Url.Action("Index", "Activity"));
}

When I create my cookie… I can simple store “ClientUser”, “Supplier” or whatever role they are inside the cookie.

Then I can create an Attribute and read in the cookie data to see if they are a valid user e.g.

public class ClientAuthorizationAttribute : AuthorizeAttribute
    {
        public bool AlwaysAllowLocalRequests = false;
        protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext)
        {
            if (AlwaysAllowLocalRequests && httpContext.Request.IsLocal)
            {
                bool authorized = false;
                var result = UserDetails.GetTypeFromTicket(httpContext.User.Identity as FormsIdentity);

                if (result.Equals("client", StringComparison.OrdinalIgnoreCase))
                {
                    authorized = true;
                }
                //throw no access exception?
                return authorized;
            }
            return base.AuthorizeCore(httpContext);
        }
    }

Register the attribute under my base controller and I have a simple working solution???

  • 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-22T19:32:40+00:00Added an answer on May 22, 2026 at 7:32 pm

    Write a custom MembershipProvider and a Custom RoleProvider then you can decorate your controler class or specific methods with the attribute

    <Authorize(Roles:="ROLENAME")>
    

    You can learn how to make that your asp mvc use the custom membershiprovider in this question It’s really easy.

    Edited:
    The way you did it looks right, but I think you take the long way. Implementing your own MembershipProvider and your own Roleprovider will take you no more than 20 minutes… and you will have the benefits of being working with a well tested and documented system and still having the benefits of use your own database tables for the login. In a simple login system, you only have to write two functions in the roleprovider (GetRolesForUser and IsUserInRole) and only one function in the membershipprovider (ValidateUser) and you will get your system working.

    If you want, I can put somewhere (maybe pastebin) a well commented versión of a membershipProvider as well of a roleprovider that i’m using in a simple app (they’re made in vb.net but i’m sure it will not be a problem)

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

Sidebar

Related Questions

I'm looking to develop an application which will have three different types of users,
I have an application that allows different users to update some data that is
I am building an app in which the users can have different roles (like
I have a rails application that has three different types of users and I
I have several entities which respresent different types of users who need to be
I have a Rails app that uses STI to handle different types of Users,
I have an application that has many different types of objects that each persist
we have an application that needs to send out various different types of template
I have different types of Roles to take into account when authorizing a user.
I have build a grails application, which on login redirects users to different URLs

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.