ASP.NET MVC 和身份验证的示例

4

我正在寻找一些使用集成的asp.net表单身份验证基于会员提供者的编辑和发布方案的asp.net mvc示例。在这里,我正在寻找最佳实践。

假设我的数据库中有一个名为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.
}

有没有关于这个的提示或指南?

1个回答

3

我还没有深入了解它的细节......但是,这个东西可能有帮助吗?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接