无法在用户管理器中访问 CreateAsync [英] Unable to access CreateAsync in User Manager

查看:21
本文介绍了无法在用户管理器中访问 CreateAsync的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的 Asp.Net Identity 系统.我在 asp.net 网站上搜索过这个,并找到了一个教程 此处.

I'm trying to use the new Asp.Net Identity system. I've searched this in asp.net site and able to find a tutorial here.

我已经为它创建了 Register 操作和适当的视图.但是无法进一步编码,因为我在身份系统中使用 User Manager 感到震惊.

I've created Register action and appropriate view for it. But Unable to code it further as I'm struck using User Manager in Identity System.

准确地说,它就在这里.

To be precise, It's here.

var result = await UserManager.CreateAsync(user, register.Password);

UserManager 类抛出异常

Using the generic type 'Microsoft.AspNet.Identity.UserManager<TUser,TKey>' requires 2 type arguments    

我的问题是为什么教程的作者没有得到任何异常?我是否缺少任何依赖项?

My question is why did the author of the tutorial did not get any sort of exceptions ? Am I missing any dependencies ?

asp.net 站点中的文档似乎也不是那么完美.

It seems like the documentation is not so perfect in asp.net site as well.

任何帮助将不胜感激.

推荐答案

var result = await UserManager.CreateAsync(user, register.Password);

上述语句中的 UserManager 不是我预期的 Class.它是 UserManager 类型的属性.

The UserManager in the above statement is not a Class as I've expected. Its a property of type UserManager<ApplicationUser>.

所以,一开始只是将一个属性声明为

So, at the beginning just declared a property as

public UserManager<ApplicationUser> UserManager { get; private set; }

现在我可以使用 Async 版本来创建用户.以下语句有效.

And now I can use the Async version for creating users. The following statement works.

var result = await UserManager.CreateAsync(user, register.Password);

这篇关于无法在用户管理器中访问 CreateAsync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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