MVC4: which entity represents the webpages_Membership table

I am trying to access the webpages_Membership table (I use SimpleMembership) to get a ConfirmationToken confirmation.

How do I access this table from my model / controller / DAL?

The only thing I can think of is to execute pure SQL from my code to get this value, but this is not like what needs to be done, and not elegant.

+6
source share
1 answer

From what I understand, there is no direct way to get the value using WebSecurity helper.

When creating a user and an account, the method returns a confirmation token:

 string confirmationToken = WebSecurity.CreateUserAndAccount("tester", "test123", requireConfirmationToken: true); 

Then you send this token (inside the link as a QueryString parameter, for example) to the user's email address. When the user clicks on the link, your application should receive / read this token, and then you should call:

 WebSecurity.ConfirmAccount(userName, confirmationToken); 

As you already mentioned, you can of course get into db directly by writing your own SQL, or even add webpages_Membership to the EntityFramewok EDMX model and query the table directly:

 var confirmationToken = Database.Memberships.Single(m => m.UserId == userId).ConfirmationToken; 

More on this:

Using ASP.NET Web Security

Get confirmation of subscription confirmation?

+2
source

Source: https://habr.com/ru/post/926034/


All Articles