views:

1127

answers:

1

I'm looking for some examples for asp.net mvc that use the integrated asp.net forms-authentication based membership providers with edit and post scenarios. I'm looking for best practices here.

Let's say I have a Contacts table in my database with a Name field, and a UserId field which is tied to the aspnet_Users UserId 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 guides to this one?

+4  A: 

Umm.. I havent gone into the details of it yet... but, could this help?

Adhip Gupta