结构图Web Api 2帐户控制器和个人帐户

我非常喜欢IOC和web-api 2,但是我已经使用了StructureMap来处理web-api中我自己的控制器2.我没有管理的是使用个人帐户在AccountController上使用StructureMap。 我使用AccountController开箱即用,到目前为止我所管理的是:

  1. 在Ioc.cs中我添加了以下内容(由于错误)

    x.For<IUserStore>().Use<UserStore>(); x.For().Use(() => new ApplicationDbContext()); x.For<ISecureDataFormat() .Use<SecureDataFormat>(); 

但是现在我遇到了这个错误:

“没有注册默认实例,无法自动确定类型IDataSerializer ”

我真的不知道该怎么做。 我试图找到IDataSerializer的详细实例,但没有运气。

顺便说一句……我已经安装了Nuget包“Structuremap.webapi2”

解决了!

将此配置添加到IoC.cs或DefaultRegistry:

  For>().Use>(); For>().Use(); For().Use(() => new DpapiDataProtectionProvider().Create("ASP.NET Identity")); For().Use(); For>().Use>(); For().Use(() => new ApplicationDbContext());