问题标签 [asp.net-identity]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
5 回答
36821 浏览

c# - Is ASP.NET MVC 5 incompatible with the WebMatrix SimpleMembershipProvider?

We have an existing application that was build on ASP.NET MVC 4 & Web API. The admin parts of the site use Simple Membership. I'm interested in upgrading the application to MVC 5 / Web API 2, to take advantage of some of the new features that have been added. But it looks like they might be incompatible.

Specifically, after installing the RC packages from NuGet into one of the projects in my solution, and updating the web.config information, the application starts dying during startup on the line that calls WebSecurity.InitializeDatabaseConnection(), with this exception:

Other projects in the same solution using Simple Membership that I have not upgraded continue to work just fine.

Googling around for more information turns up lots of hits for that exception, of course, but nothing particular to WebMatrix.

FWIW: I know that Microsoft has introduced (yet another) membership and identity solution, but unless there's a way to use that with the existing Simple Membership tables, or a seamless migration path for all of our existing user data, that's not really an option for us.

UPDATE (11 Oct)

I just tried this again with a fresh checkout of the current trunk of our app. I'm using Visual Studio 2012, but otherwise followed the instructions from MS for upgrading an existing project. After updating to MVC 5 / Web API 2 / EF 6, the app started up an ran just fine.

There were no explicit trust requirements in the web.config to remove. I added the code from this question to Global.asax.cs, and it reports that the app is running with full trust (in IIS Express, just F5-ed from VS).

Re-adding the same call to InitializeDatabaseConnection(), it starts dying with the exact same exception.

SOLUTION (28 Oct)

Trying the solution in @Kevin's update from Friday, I found that it works. It was really strange to me that adding this apparently unrelated package would solve these security issues, and even more strange after I removed the package from my solution, and it kept working.

Taking a closer look at what was happening, I realized that the reason why this fixes the behavior is quite simple: the Microsoft.AspNet.WebHelpers package has two dependencies that were being added to my solution: Microsoft.AspNet.WebPages.Data and Microsoft.AspNet.WebPages.WebData. Microsoft has moved the WebMatrix classes into new packages.

So added the helpers package fixed the problem, not because of anything it was doing, but because it was causing updated versions of the broken assemblies to be added to my solution. The solution to the initial incompatibility, then, is to install these new packages when updating everything else from NuGet:

UPDATE (13 May 2015)

It has been suggested to me that you may also need to manually install the second new package:

This should not be necessary, because this package is an explicit dependency of the first, and NuGet should be smart enough to install both. But if you get an error when building, or don't see NuGet add the dependency, it might help you.

0 投票
1 回答
8166 浏览

c# - 无法让“UseOAuthBearerTokens”与 Owin 和 Identity RTM 一起使用

我用

但 url http://example.com/Token/返回错误:

无法找到该资源。

0 投票
3 回答
6385 浏览

asp.net - 从旧的 ASP.NET 成员身份切换到 ASP.NET 身份 (Visual Studio 2013)

介绍 ASP.NET Identity – ASP.NET 应用程序的成员系统

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 Identity”。

我设法让我的应用程序通过内置的注册/登录/更改密码功能使用我的 MSSQL 数据库,但我不确定如何像过去那样进行其他操作(尤其是“ASP.NET 配置”已经消失)。由于这是新事物,因此我找不到任何好的指南,或者我的想法有误。

  1. “[dbo].[AspNetUsers]”现在在 nvarchar(128) 中具有 [Id],而不是 uniqidentifier,但仍为 GUID 格式
  2. Membership.GetUser().ProviderUserKey 不再起作用,我如何获取 ID?(通过 User.Identity.Name 获取用户名,然后查询 [dbo].[AspNetUsers]?”
  3. 除了直接操作数据库之外,如何创建(管理)角色?(和之前的 System.Web.Security.Roles.CreateRole 方法一样)

ETC

如果任何人都可以提供有关如何实现此“ASP.NET Identity”的详细介绍的链接,那将是最好的

非常感谢..

更新

我发现可以通过以下方式检索 Id:(new System.Linq.SystemCore_EnumerableDebugView(((System.Security.Claims.ClaimsPrincipal)(((System.Web.UI.Page)(this)).User)).Claims)) .Items[0].值

它在索赔中..但看起来效率不高。

0 投票
3 回答
7276 浏览

entity-framework - 自定义 ASP.NET Identity (OWIN) 使用实体框架的详细信息

这个博客:

http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx

关于 ASP.NET 身份提供者状态:

持久性控制

默认情况下,ASP.NET 身份系统会将所有用户信息存储在数据库中。ASP.NET Identity 使用 Entity Framework Code First 来实现其所有的持久性机制。

如果您的应用程序要求此信息可能存储在不同的存储机制中,例如 SharePoint、Azure 表服务、No Sql 数据库等。现在可以插入不同的存储提供程序。

但是如何使用 Azure 表服务呢?我的研究表明您不能将实体框架与表服务一起使用,因此我认为您必须完全替换使用实体框架的代码,但我不确定。

相关问题:我一般是 EF 的新手。我们如何自定义数据的存储方式(甚至在 SQL Server 中)?我发现了两个示例,它们显示向用户表添加额外字段:

http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

http://www.asp.net/web-api/overview/security/external-authentication-services

但我不清楚到底发生了什么。我认为它首先使用实体​​框架代码,但我看到的关于如何自定义 EF 如何为此存储数据的文档很少。例如,我可以重命名实体吗?我可以定义将调用什么数据库吗?

谢谢...

-本

0 投票
1 回答
11793 浏览

asp.net - 在 MVC 4 中使用 ASP.Net 标识

我一直在阅读即将发布的 ASP.net 版本中的新身份验证内容:http: //blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership -system-for-asp-net-applications.aspx

我正在 Visual Studio 2012 中创建一个新的 ASP.net MVC 4 项目,如果可以的话,我想使用新的身份验证位。这可能吗?

我正在阅读代码并试图围绕这个新 API 进行思考。但与此同时,要采取哪些步骤?

0 投票
3 回答
10192 浏览

asp.net - 为什么 ASP.NET Identity 接口使用字符串作为主键和外键?

我正在查看新的 ASP.NET Identity 类的接口以及它使用 Entity Framework Code First 创建的数据库。我正在使用 Visual Studio 2013 RC。

乍一看,数据库模式看起来相当正常:

在此处输入图像描述

但是所有的键都是 NVARCHAR(128)

出于某种疯狂的原因AspNetUserSecrets.Id,PK 看起来可能指向AspNetUsers表格中的多个记录。这是否意味着多个AspNetUsers必须共享相同的密码?

当我查看查看您被迫实现的接口时,这些都是字符串...

所以我开始接受这样一个事实,即我可能必须使用字符串来实现 PK 和 FK 关系。

但我真的很想知道为什么它是这样建造的......?

编辑:时间已经过去,现在有关于如何扩展 asp.net 身份以使用 int(或 guid)字段的文章:

http://www.asp.net/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity

0 投票
1 回答
419 浏览

asp.net-identity - 如何获得 Microsoft.AspNet.Identity nuget 包的 RTM 每晚版本?

我正在运行 Premium VS2013 RC
我已在https://www.myget.org/
注册 我已添加www.myget.org/f/aspnetwebstacknightly为存储库

我尝试了几种方法来获取这些 nuget 包,包括发出以下包管理器控制台命令:

update-package Microsoft.AspNet.Identity.Core -IncludePrerelease -source http://www.myget.org/F/aspnetwebstacknightly/

这给了我一个错误The remote server returned an error: (407) Proxy Authentication Required.

当我尝试拉取或搜索包时,我被要求提供凭据,我得到了这个对话框(我在 myget.org 注册时创建的凭据不起作用)。

![连接到 www.myget.org][1]

更新:我关注了博客 http://blogs.msdn.com/b/webdev/archive/2013/10/09/asp-net-identity-nuget-packages-for-the-nightly-builds-are-available -on-myget.aspx

编辑:

当我从:

至:

它开始工作了!

0 投票
3 回答
29810 浏览

c# - 使用 MVC 5 和 Asp.net 身份进行电子邮件确认

我一直在搜索,但没有找到任何关于如何使用新的 ASP.net 身份使用 MVC 5 实现电子邮件确认的文档。似乎没有关于这个主题的任何文档(我可以找到)。

有人解决了这个问题吗?我很惊讶默认情况下这不包含在默认的 MVC 5 项目中。

非常感谢任何指导。

谢谢你

0 投票
1 回答
1488 浏览

authentication - 如何更改 Owin.AuthenticationIdentityManager 的 PasswordValidator 设置?

此自动生成的代码注册了一个新用户:

我们如何更改密码验证设置?
这是我使用 dotPeek 发现的:
AuthenticationIdentityManager 类实例包含 UserManager,它使用 PasswordValidator 验证密码:
来自 Microsoft.AspNet.Identity.UserManager 类:

Microsoft.AspNet.Identity.IdentityOptions 类:

我找不到可以访问或替换 IdentityOptions 实例的位置。有没有示例或文档?

0 投票
1 回答
311 浏览

c# - ASP.NET Identity RTM 及其版本

根据这篇文章,现在可以在 MyGet 上使用 ASP.NET Identity nighlty 包。

http://blogs.msdn.com/b/webdev/archive/2013/10/09/asp-net-identity-nuget-packages-for-the-nightly-builds-are-available-on-myget.aspx

但是,我发现 nightly build 中出现的版本是“1.1.0-alpha1-131011”,这似乎是在版本 1 RTM 之后。或者 RTM 将是 1.1 版?

ASP.NET Identity RTM 何时发布?