【发布时间】:2015-10-20 18:53:07
【问题描述】:
我在 Web API 2 项目中使用 ASP.NET Identity 2.2,但我不确定如何使用 Autofac 连接 AccountController 的 ISecureDataFormat<AuthenticationTicket> 依赖项。
我试过这个:
builder.RegisterType<ISecureDataFormat<AuthenticationTicket>>()
.As<TicketDataFormat>();
并得到错误:
类型“Microsoft.Owin.Security.ISecureDataFormat`1[Microsoft.Owin.Security.AuthenticationTicket]”不可分配给服务“Microsoft.Owin.Security.DataHandler.TicketDataFormat”
我遇到的所有问题似乎都不适用于最新的稳定版本的 ASP.NET Identity。
非常感谢任何帮助。
【问题讨论】:
-
您能与我们分享您的尝试和错误信息吗?
-
我试过这个:
builder.RegisterType<ISecureDataFormat<AuthenticationTicket>>().As<TicketDataFormat>();并得到错误:类型 'Microsoft.Owin.Security.ISecureDataFormat`1[Microsoft.Owin.Security.AuthenticationTicket]' 不能分配给服务 'Microsoft.Owin .Security.DataHandler.TicketDataFormat'。
标签: asp.net dependency-injection asp.net-web-api2 autofac asp.net-identity-2