Asp.net 使用Autofac在Web API 2 AccountController中注入ISecureDataFormat
我在Web API 2项目中使用ASP.NET Identity 2.2,但我不确定如何使用Autofac连接Asp.net 使用Autofac在Web API 2 AccountController中注入ISecureDataFormat,asp.net,dependency-injection,asp.net-web-api2,autofac,asp.net-identity-2,Asp.net,Dependency Injection,Asp.net Web Api2,Autofac,Asp.net Identity 2,我在Web API 2项目中使用ASP.NET Identity 2.2,但我不确定如何使用Autofac连接AccountController的ISecureDataFormat依赖关系 我试过这个: builder.RegisterType<ISecureDataFormat<AuthenticationTicket>>() .As<TicketDataFormat>(); builder.RegisterType() .As();
AccountController
的ISecureDataFormat
依赖关系
我试过这个:
builder.RegisterType<ISecureDataFormat<AuthenticationTicket>>()
.As<TicketDataFormat>();
builder.RegisterType()
.As();
和获取错误:
类型“Microsoft.Owin.Security.ISecureDataFormat”1[Microsoft.Owin.Security.AuthenticationTicket]'不可分配给服务“Microsoft.Owin.Security.DataHandler.TicketDataFormat”
使用最新的稳定版本ASP.NET Identity,我遇到的所有问题似乎都不起作用
非常感谢您的帮助。您必须访问oposite。使用Autofac可以将类型注册为服务
builder.RegisterType<TicketDataFormat>()
.As<ISecureDataFormat<AuthenticationTicket>>();
你必须做这个网站。使用Autofac可以将类型注册为服务
builder.RegisterType<TicketDataFormat>()
.As<ISecureDataFormat<AuthenticationTicket>>();
您能和我们分享一下您尝试了什么以及错误消息是什么吗?我尝试了这个:
builder.RegisterType().As()代码>和获取错误:类型“Microsoft.Owin.Security.ISecureDataFormat`1[Microsoft.Owin.Security.AuthenticationTicket]”无法分配给服务“Microsoft.Owin.Security.DataHandler.TicketDataFormat”。您可以与我们共享您尝试的内容以及错误消息吗?我尝试了以下操作:builder.RegisterType().As()代码>和获取错误:类型“Microsoft.Owin.Security.ISecureDataFormat`1[Microsoft.Owin.Security.AuthenticationTicket]”不能分配给服务“Microsoft.Owin.Security.DataHandler.TicketDataFormat”。