我掙扎在使用StructureMap和微軟ASPNET身份在一起,我似乎無法弄清楚如何獲得IAuthenticationManager的實現映射映射IAuthenticationManager實現。我試圖在下面的例子中明確地將這個映射到DefaultRegistry中。如何讓StructureMap
public class DefaultRegistry : Registry {
public DefaultRegistry() {
Scan(
scan => {
scan.TheCallingAssembly();
scan.WithDefaultConventions();
scan.With(new ControllerConvention());
});
For<IAuthenticationManager>().Use(() => HttpContext.Current.GetOwinContext().Authentication);
}
}
的主要問題是,HttpContext.Current總是空,但我什至不知道這會工作,即使不爲null。我是一個有StructureMap和AspNet Identity的新手,所以隨時可以給我打電話,讓我知道我在這裏做的任何傻事。謝謝你的幫助!