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?
source share