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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:01:52+00:00 2026-06-03T01:01:52+00:00

I am a newbie when it comes to ASP.NET MVC so it would be

  • 0

I am a newbie when it comes to ASP.NET MVC so it would be great if anyone could provide guidance with the following scenario.

Loooking at a scenario whereby there will be two types of members that can register to a site, clients and suppliers.

Each type will be a member with additional information being stored in separate models/tables (i.e. Client model/table, Supplier model/table), along with default member credentials (username, email, password). Not sure of the best approach for this. Any recommendations welcome?

There will be a separate register page for each type, whereby upon successful registration they will be added to their respective role (i.e. Client, Supplier).

Here is the Client model that I’m playing with.

public class Client
{
  // Will set this manually when creating a Client member
  [DatabaseGenerated(DatabaseGeneratedOption.None)]
  public int ClientId { get; set; }
  public string FirstName { get; set; }
  public string LastName { get; set; }
}

Currently I’ve created a ViewModel as follows to handle registration for a Client

public class RegisterClient
{
  // Default ASP.NET MVC RegisterModel
  public RegisterModel RegisterModel { get; set; }
  public Client Client { get; set; }
}

Below are the Register methods in the ClientController

public ActionResult Register()
{
  return View();
}

[HttpPost]
public ActionResult Register(RegisterClient model)
{
  if (ModelState.IsValid)
  {
    // Attempt to register the user
    MembershipCreateStatus createStatus;
    Membership.CreateUser(model.RegisterModel.UserName, model.RegisterModel.Password, model.RegisterModel.Email, null, null, true, null, out createStatus);

    if (createStatus == MembershipCreateStatus.Success)
    {
      FormsAuthentication.SetAuthCookie(model.RegisterModel.UserName, false /* createPersistentCookie */);
      Roles.AddUserToRole(model.RegisterModel.UserName, "Client");
      // Get UserId for Client <-> User relationship
      int id = int.Parse(Membership.GetUser(model.RegisterModel.UserName).ProviderUserKey.ToString());
      model.Client.UserProfileId = id;
      db.Clients.Add(model.Client);
      db.SaveChanges();
      return RedirectToAction("Index", "Home");
    }
    else
    {
      ModelState.AddModelError("", createStatus.ToString());
    }
  }
  // If we got this far, something failed, redisplay form
  return View(model);
}

Is this a suitable approach? I was thinking of having the Client model inheriting MembershipUser.

How can I then create a page listing of Clients along with their membership details (i.e. username and email)?

  • 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-03T01:01:57+00:00Added an answer on June 3, 2026 at 1:01 am

    I have developed a system with two levels of user and the easiest way to store type specific information is to have separate tables and then to assign them a linking pieces of information, in the past I assigned all users a customer ID and then record it in the type specific tables as well. When I have wanted to look for their information I would check the users customer id then check it against the id of the record be accessed.

    I your situation I would add a associate id column to both the client and supplier model. The associate ID could be the username but I have found that the best way would be to have a separate users table that links the username in asp.net membership to the associate id. Then you could easily check if the user is a client or a supplier by looking for the current users associate id in both tables. This approach means that latter if your suppliers or clients have many user accounts they can all access the same set of data. You could still use ASP.Net membership roles to perform part of the authorization ,but you should check the associate id before you show the record to the user.

    UPDATE 02/05/2012:

    You could create models for your user’s and client’s like the one’s below.

    public class User
    {
        public int UserId{ get; set; }
        //This is from ASP.Net Membership
        public string Username { get; set; }
        public int AssosiateId { get; set; }
    }
    
    public class Client
    {
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int ClientId { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    
        //This is the ID of the Assosiate - the same as the user's assosiate id
        public int AssosiateId { get; set; }
    }
    

    You would create a class similar to the client’s one above for suppliers.

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

Sidebar

Related Questions

I'm a newbie when it comes to client/server app. (I only programmed asp.net apps)
I am a newbie when it comes to using WinAPI. I am following a
I am newbie in SharePoint 2010 but have experience in ASP.NET (C#) development. I
I'm creating a discussion forum (of sorts) in ASP.NET MVC, and I have a
I am a newbie if it comes to web site development. I would like
Good morning, Apologies for the newbie question. I'm just getting started with ASP.NET internationalization
I'm a .NET and MVC newbie, and learning it for the first time after
I am a newbie when it comes to trunk/branch so my question my be
I'm a complete newbie when it comes to HTML, I've never needed to do
I'm a total newbie when it comes to CSS so I've pretty much given

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.