【发布时间】:2008-10-18 21:46:56
【问题描述】:
我正在寻找一些 asp.net mvc 示例,这些示例使用基于集成 asp.net 表单身份验证的成员资格提供程序以及编辑和发布方案。我正在这里寻找最佳做法。
假设我的数据库中有一个 Contacts 表,其中包含一个 Name 字段和一个与 aspnet_Users UserId 字段相关联的 UserId 字段。我想到了这样的事情:
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.
}
对此有任何提示或指南吗?
【问题讨论】:
标签: asp.net-mvc asp.net-membership forms-authentication