ASP.NET Identity 2-注入ISecureDataFormat [英] ASP.NET Identity 2 - injecting ISecureDataFormat<>

查看:95
本文介绍了ASP.NET Identity 2-注入ISecureDataFormat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此处没有答案,仅使用Unity.

I'm having same issue described here with no answer, just using Unity.

我正在尝试在最新的VS2013(更新2)SPA/Web Api模板中注册ISecureDataFormat<>.

I'm trying to register ISecureDataFormat<> in the lastest VS2013 (update 2) SPA/Web Api template.

我尝试过

container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>));
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>();
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>();

它起作用",但不是真的,因为它随后抱怨该树中的下一个依赖关系,即IDataSerializer ...,然后是下一个IDataProtector,但我没有实现.

It "works" but not really because then it complains about the next depenedency in that tree, IDataSerializer... and then the next IDataProtector, for which I found no implementation.

推荐答案

我通过以下映射解决了SimpleInjector中的以下错误

I solved the following error in SimpleInjector with the following mappings

container.Register<IDataSerializer<AuthenticationTicket>, TicketSerializer>();
container.Register<IDataProtector>(() => new DpapiDataProtectionProvider().Create("ASP.NET Identity"));

要弄清楚使用了什么序列化程序,我注意到AccountsController中的ISecureDataFormat通用参数是AuthenticationTicket类型.在检查IDataSerializer命名空间时,TicketSerializer实现IDataSerializer.

To figure out what serializer was used I noticed that the ISecureDataFormat generic parameter in the AccountsController was a AuthenticationTicket type. In checking the IDataSerializer namespace the TicketSerializer implements IDataSerializer.

要弄清楚IDataProtector,我再次查看了IDataProtector命名空间,并找到了IDataProtectionProvider的实现.

To figure out IDataProtector I again looked in the IDataProtector namespace and found the implementation of the IDataProtectionProvider.

这篇关于ASP.NET Identity 2-注入ISecureDataFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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