Register IAuthenticationManager with Simple Injector

后端 未结 3 1238
春和景丽
春和景丽 2020-11-30 03:40

I am having a configuration setup for Simple Injector where I have moved all of my registrations to OWIN pipeline.

Now the problem is I have a controller Acco

3条回答
  •  萌比男神i
    2020-11-30 04:15

    What you are doing with IAuthenticationManager registration worked for me with no issues. At some point I was getting the same exception as you were getting, but that was caused by line with

    container.Verify();
    

    just after the container configuration. It was trying to create all instances of registered objects, but there was no HttpContext.Current present, hence the exception.

    Are you not getting any instances out of container before any HTTP request is available? If you really need them, then the only way to work around this is use Factory, as suggested by NightOwl888. If you don't need container before the HTTP request, then refactor, so it is not use outwith HTTP request.

提交回复
热议问题