Alternative User management in ASP.NET MVC

后端 未结 3 1023
既然无缘
既然无缘 2020-12-29 13:57

I am in the planning phase of a new ASP.NET MVC application and one of the requirements is storing some user information that is not part of the standard set found in the Us

相关标签:
3条回答
  • 2020-12-29 14:39

    See ASP.Net MVC Membership Starter Kit. It provides the Asp.Net MVC controllers, models, and views needed to administer users & roles. It will cut distance in half for you.

    Out of the box, the starter kit gives you the following features:

    • List of Users
    • List of Roles
    • User Account Info
    • Change Email Address
    • Change a User's Roles
    0 讨论(0)
  • 2020-12-29 14:44

    Look into profiles that are part of the membership functionality provided by MS. They are extendable and pretty flexible.

    0 讨论(0)
  • 2020-12-29 14:59

    Profiles are one option as @Burt says, and offers a lot of flexibility.

    I had a similar need to track Employee information, but I opted to roll my own Employee class and create a relationship to a standard User. I really like how this has worked out as I can keep any Employee specific business logic separate from the User class Membership system.

    Since not every User was going to be bound with an employee, this made more sense for my case. It may not for yours, but it is an alternative.

    So, I have something like:

    public class Employee
    {
        public Employee(string name) : this()
        {
            Name = name;
        }
    
        public virtual string Name { get; set; }
        public virtual string Title { get; set; }
        public virtual decimal Salary { get; set; }
        public virtual decimal Hourly { get; set; }
        public virtual decimal PerDiem { get; set; }
        public virtual string StreetAddress { get; set; }
        public virtual Guid UserId { get; set; }
        public virtual MembershipUser User {
            get
            {
                // note that I don't have a test for null in here, 
                // but should in a real case.
                return Membership.GetUser(UserId);
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题