问题标签 [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 投票
1 回答
169 浏览

asp.net - 我在哪里可以获得 asp.net 身份的 rtm 控制器模板?

我知道它不是开源的(还),但有人知道如何使最新的 rtm 包工作,或者我可以用来试用它的控制器模板吗?

它似乎与 RC 版本相比发生了重大变化。

0 投票
1 回答
1551 浏览

asp.net - ASP.NET MVC 5 身份和 Azure

我正在尝试Visual Studio 2013 RC使用MVC 5 spa template.

我可以让注册/登录/注销过程正常工作,除非有一个小问题困扰着我。如果我尝试使用错误的凭据登录,返回页面的错误字符串是“发生未知错误”。而不是“用户名或密码不正确”。如果GrantResourceOwnerCredentialsinApplicationOAuthProvider.cs工作正常,它应该是这样。

在 localhost 上,我得到正确的“用户名或密码不正确”。信息。

Azure 的错误日志:

我不确定它怎么可能是格式错误的语法,因为在提交正确的登录凭据时会发送和处理相同的语法。

有没有人对此有足够的了解,可以知道发生了什么,或者至少有一条途径可以接近知识库文章以外的答案?如果还不是很明显,我是新手——这是我在 ASP.NET 中的第一个网站,第一次介绍 OAuth,第一次使用 Azure。

0 投票
3 回答
50057 浏览

asp.net-mvc - 将异步与 MVC5 一起使用有什么好处?

有什么区别:

和:

我看到 MVC 代码现在有异步但有什么区别。一个提供比另一个更好的性能吗?调试一个问题比另一个更容易吗?我应该对其他控制器进行更改以使我的应用程序添加 Async 吗?

0 投票
1 回答
85799 浏览

c# - How do you login/authenticate a user with Asp.Net MVC5 RTM bits using AspNet.Identity?

Apologies and Thanks in advance for this question! I am still new to SO.

I have been working on a web application using MVC5, EF6, and VS 2013.

I spent some time upgrading to the RC bits once released. Thanks to all the great posts out there: eg. Decoupling Microsoft.AspNet.Identity.* and Updating asp.net MVC from 5.0.0-beta2 to 5.0.0-rc1 !

In my infinite wisdom, I decided to move to the RTM bits that @Hao Kung posted about here: How can I get early access to upcoming Asp.Net Identity changes?. I figured I would save the trouble and not be too far behind when we finally receive the RTM build.

This has either been a nightmare, or I am just completely missing something (or both) as I can not figure out basic tasks that had been working with the RC1 stuff.

While it seems like I am logging the user in via the controller (Where is Microsoft.AspNet.Identity.Owin.AuthenticationManager in Asp.Net Identity RTM version?) ... my WindowsIdentity is always empty and not authenticated after I call SignIn. The user and claimsIdentity object are correctly populated.

Here is the action method I am calling (moved properties to local variables for completeness):

(On a side note: I do not need to log in external users at this time.)

Any suggestions? -or- Should I roll back all my changes and just wait until VS 2013 is RTMd?


Update, refactored code to make it closer to @Hao Kung's original reply. However I still do not end up with a valid user identity. I think my AuthenticationManager is not assigned correctly?

AuthenticationManger is now defined as:

SignInAsync is now a separate method:

After "SignOut", the debugger shows:

The "claimsIdentity" is then:

"SignIn" does not change anything:

Still no Authentication, but seems that no errors are thrown.


As answered by @Hao Kung, changed StartUp.Auth.cs from:

To:

0 投票
2 回答
13368 浏览

c# - ASP MVC 5 (Microsoft.AspNet.Identity) 中的角色管理

在 ASP MVC5 RC 中,我没有让角色系统工作。我的数据库有一个角色存在的所有需求表,但是如果用户在角色中进行校对总是返回 false(没有 SQL 异常或其他东西)!?

我需要在IPrincipal某个地方激活角色系统吗?

测试代码:

我还尝试构建自定义扩展,例如命名空间中的IIdentity.GetUserId()扩展方法Microsoft.AspNet.Identity.Owin

但是索赔类型的结果RoleClaimType总是null:(我真的坚持这一点。

谢谢您的帮助!史蒂芬

0 投票
2 回答
2403 浏览

c# - 查询语法中的异步方法

我学习了 asp.net 身份,async/await,我遇到了这个问题:

我有一些功能IEnumerable<T> list。我使用查询语法填写的这个列表如下所示:

在 SomeModel 中是IsAdminbool (当我在 GetPermission 中尝试时,我Task<bool>在 SomeModel 中使用Task<bool>)。里面GetPermission()是这样的:

我尝试使用 async/await 和作为 Task 进行写入,但我的两次尝试都是错误的。所以我认为我必须在GetPermission()外面调用,IEnumerable<SomeModel> persons所以我在之后将这段代码添加到条件中。所以代码看起来像这样:

但这也是错误的。也许我对 asp.net 身份和 async/await 及其使用理解不好......你能帮我吗 - 我必须做什么?因为现在,GetPermission调用太晚了,所以app崩溃了。当我调用GetPermission人员查询时,调用函数也太晚了(在填写人员列表之后)。我不知道如何继续。

GetUser()public IUser GetUser(string username)GetRoles()一样public async Task<IEnumerable<IRole>> GetRoles(string userId)。_ 我敢肯定,这两种方法都可以正常工作,我在其他代码中使用它们并且没有问题。所以我认为它必须在上面的代码中的某个地方。

对不起,如果这是个愚蠢的问题,但我在这里和 msdn 上读到了很多,但找不到结果。谢谢大家。


为什么我想像上面那样使用异步功能

我想要那里的函数,因为当我将整个函数作为异步任务时,另一个调用它的函数不能正常工作。

我有这个功能 - 它是 kendogrid () 的数据绑定:

当我将函数IEnumerable<SomeModel> GetPersons作为async Task<IEnumerable<SomeModel>> GetPersons绑定函数不知道 ToDataSourceResult() 时,当我将此函数作为异步函数时。如果这里有问题,我该如何解决?请耐心等待我,我是新手...

0 投票
1 回答
371 浏览

c# - ASP.NET 身份框架 UserSecret 没有 UserId 列

我正在 Mvc 5 和新的 Asp.net Identity 上开发多租户应用程序。挑战在于两个用户可以有相同的用户名,只是不在同一个租户上。我在很大程度上已经弄清楚了,但由于某种原因,Identity 框架生成的所有表都有一个 UserId 列,除了 UserSecret 实体的表。是否有一个原因?我想确保在将其替换为具有 UserId 列的实现之前没有遗漏任何内容。

0 投票
2 回答
954 浏览

c# - 如何使用 AspNet.Identity 创建具有 Asp.Net RTM 位的用户?

如何使用 AspNet.Identity 创建具有 Asp.Net RTM 位的用户?

我转到了@Hao Kung 在此处发布的 AspNet Identity RTM 位:如何提前访问即将到来的 Asp.Net Identity 更改?

用于注册用户的 RC Asp.Net 身份代码如下所示...

我的问题与此处发现的问题类似... 您如何使用 AspNet.Identity 登录/验证具有 Asp.Net MVC5 RTM 位的用户?

但我问的是创建用户,而不是登录。

0 投票
4 回答
27343 浏览

c# - ASP.NET Identity Cookie across subdomains

For forms authentication I used this in web.config (note the domain attribute):

How is a single sign-on across subdomains configured for the new ASP.NET Identity Framework in Mvc 5?

More Info:

I am creating a multitenant application. Each client will be on a subdomain:

client1.myapp.com

client2.myapp.com

I want a user to be able to sign on to client1.myapp.com and then go to client2.myapp.com and still be signed in. This was easy with forms authentication. I'm trying to figure out how to do it with the new Identity Framework.

EDIT

Here is the code that eventually worked for me:

0 投票
1 回答
328 浏览

asp.net-identity - 从 AspNet Identity Release Candidate 到 RTM

我缺少 IIdentityManagerFactory ,是替代 UserManager 吗?

我也很难找到替代品LocalLoginProvider = UserManager.Settings.GetIdentityOptions().LocalLoginProvider

和这个

我错过了一个替代品 IdentityAuthenticationOptions options = identityManager.Settings.GetAuthenticationOptions();

为外部登录创建 ClaimsIdentity。