开关旧ASP.NET成员到ASP.NET识别(Visual Studio的2013年) [英] Switch from old ASP.NET Membership to ASP.NET identity (Visual Studio 2013)

查看:134
本文介绍了开关旧ASP.NET成员到ASP.NET识别(Visual Studio的2013年)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

介绍ASP.NET身份 - 会员制为ASP.NET应用程序

Introducing ASP.NET Identity – A membership system for ASP.NET applications

<一个href=\"http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx\">http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx

现在使用ASP.NET 4.5创建新的Web应用程序时,我们有新的ASP.NET身份。

Now when creating a new web application with ASP.NET 4.5, we have the new "ASP.NET Identity".

我设法让我的应用程序使用我的MSSQL数据库与注册/登录/更改密码功能构建的,但我不知道该怎么办像过去其他操作(尤其是ASP.NET配置是走了)。由于这是新的东西,我没能找到任何好的指南或我是错误的想法。

I manage to let my application to use my MSSQL database with the build in register/login/change password functions, but I am not sure how to do other operation like old days ( especially the "ASP.NET Configuration" is gone). Since this is something new, I failed to find any nice guide or I was thinking wrongly.


  1. 在[DBO]。[AspNetUsers]现在有[ID]中为nvarchar(128),而不是uniqidentifier,但仍处于GUID格式

  2. Membership.GetUser()。ProviderUserKey不再工作,我怎么了标识? (获取用户名由User.Identity.Name然后查询[DBO]。[AspNetUsers]?

  3. 如何创建(管理)的角色旁边直接操作数据库? (如previous System.Web.Security.Roles.CreateRole法)

这将是最好的,如果任何人都可以对有关如何实现这个ASP.NET身份细节出台提供链接

it would be best if anyone can provide link for a detail introduction about how to implement this "ASP.NET Identity"

非常感谢。

更新

我找到了标识可以通过retrived:
(新System.Linq.SystemCore_EnumerableDebugView(((System.Security.Claims.ClaimsPrincipal)(((System.Web.UI.Page)(this)).User)).Claims)).Items[0].Value

I found the Id can be retrived by: (new System.Linq.SystemCore_EnumerableDebugView(((System.Security.Claims.ClaimsPrincipal)(((System.Web.UI.Page)(this)).User)).Claims)).Items[0].Value

这是索赔..但看起来不是很有效。

it is in the claim.. but looks not very efficient.

推荐答案

我在同一条船上。我发现一个更清洁的方式来获得用户ID

I'm in the same boat. I have found a cleaner way to get the userid

 var identity = new ClaimsIdentity(User.Identity);
 var id = identity.GetUserId();

这篇关于开关旧ASP.NET成员到ASP.NET识别(Visual Studio的2013年)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆