简体   繁体   中英

ASP.NET Membership Provider implementation

I'm trying to implement a customer ASP.NET Membership provider. I have no database yet, but I know I want one that's simple and accessible.

I know I don't want to use the generated tables because from what I've seen and understand, they are very convoluted and include many fields that I just won't need. I set up the default Membership provider and let it generate its own database/tables and it produced this:

在此处输入图片说明

All by itself. I don't want this mess as part of my database. So the natural solution? A custom membership provider. To do this, I know you need to inherit from System.Web.Security.MembershipProvider and setup web.config to the derived class that I create.

public class MessAround : System.Web.Security.MembershipProvider
{
public MessAround()
{

    //
    // TODO: Add constructor logic here
    //
}

public override string ApplicationName
{
    get
    {
        throw new NotImplementedException();
    }
    set
    {
        throw new NotImplementedException();
    }
}

public override bool ChangePassword(string username, string oldPassword,

 string newPassword)
{
    throw new NotImplementedException();
}

public override bool ChangePasswordQuestionAndAnswer(string username
, string password, string newPasswordQuestion, string newPasswordAnswer)
{
    throw new NotImplementedException();
}

....ETC ETC ETC

My question is:

  • How do I integrate this class into a custom database schema?

  • How do I eliminate fields that I don't need?

  • How do I get this class to interact with my database tables?

  • WTF is going on? :P

First of all, The whole ASP.Net Membership is inbuilt functionality. So there is pros and cons comes as

Pros

  • easy to use and implement
  • give all functionality of user management
  • automatically create UI, DB and relationship.

Cons

  • customization is tedious job.
  • after implementation to whole systam, to remove whole thing will make issue.

Now I give the answer one by one.

  1. How do I integrate this class into a custom database schema? For schema use, the rule is always use schema-name before object like yourschema.sp_name
  2. How do I eliminate fields that I don't need? You can't remove fields as one or more reference of fields. Why you remove fields, you just left that. I also found the same issue, in that I left and only use which I want.
  3. How do I get this class to interact with my database tables? If you are using Entity-Framenwork or linq, its get as a class of your table. Which type of interact you need? for login- logout or session management. Then check this link:

How to Check whether Session is Expired or not in asp.net

Using session variable with ASP.Net membership provider

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM