Ip asp.net 2.1 injection IAuthenticationManager using StructureMap

Can someone point me towards some samples or instructions on how to achieve this, please?

+4
source share
2 answers

This originally happened by transforming Identity to use int as unique key values, as described here .

Then I expanded this and created a custom AuthenticationManager using the IAuthenticationManager.

Then I install StructureMap as follows:

For<IAuthenticationManager>()
    .Use<MyAuthenticationManager>(
     () => new MyAuthenticationManager(HttpContext.Current.GetOwinContext().Authentication));

Thanks @trailmax

+8
source

StructureMap, Autofac SimpleInjector.

Autofac :

builder.Register(c => HttpContext.Current.GetOwinContext().Authentication).As<IAuthenticationManager>();

SimpleInjector :

container.RegisterPerWebRequest(() => HttpContext.Current.GetOwinContext().Authentication);

StructureMap, , - :

ForRequestedType<IAuthenticationManager>()
    .TheDefaultIs(() => HttpContext.Current.GetOwinContext().Authentication)
+6

All Articles