Asp.net mvc and authentication examples

I am looking for some examples for asp.net mvc that use form-based integrated membership providers based on asp.net authentication with editing and publishing scripts. I am looking for best practices here.

Say I have a contact table in my database with a "Name" field and a "UserId" field that is bound to the "UserId" aspnet_Users field. I thought of something like this:

public ActionResult Save([Bind(Include="Name")] Contact contact) { // if null etc. checks omitted for this example MembershipUser currentUser = Provider.GetUser(User.Identity.Name, true); contact.UserId = (Guid)currentUser.ProviderUserKey; //save etc. } 

Any tips or guidance on this?

+4
source share
1 answer

I have not gone into the details of this yet ... but, could this help?

+3
source

All Articles