{"action":"created","issue":{"url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/93","labels_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/93/comments","events_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/93/events","html_url":"https://github.com/simpleinjector/SimpleInjector/issues/93","id":101424376,"number":93,"title":"How to use Simple Injector in ASP.NET vNext with Asp.Net Identity","user":{"login":"kawazoe","id":406575,"avatar_url":"https://avatars.githubusercontent.com/u/406575?v=3","gravatar_id":"","url":"https://api.github.com/users/kawazoe","html_url":"https://github.com/kawazoe","followers_url":"https://api.github.com/users/kawazoe/followers","following_url":"https://api.github.com/users/kawazoe/following{/other_user}","gists_url":"https://api.github.com/users/kawazoe/gists{/gist_id}","starred_url":"https://api.github.com/users/kawazoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kawazoe/subscriptions","organizations_url":"https://api.github.com/users/kawazoe/orgs","repos_url":"https://api.github.com/users/kawazoe/repos","events_url":"https://api.github.com/users/kawazoe/events{/privacy}","received_events_url":"https://api.github.com/users/kawazoe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/simpleinjector/SimpleInjector/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-17T13:49:22Z","updated_at":"2015-08-19T20:49:33Z","closed_at":null,"body":"I've been trying to implement a vnext website with SimpleInjector using the pattern recommended in issue #41. I really like the separation it brings between first-party and third-party services, but I'm hitting a wall when trying to add support for Asp.Net Identity v3 using a custom UserStore.\r\n\r\nYou see, Asp.Net Identity normally gets registered through the DNX DI system during service configuration.\r\n\r\n```csharp\r\nservices.AddIdentity<FooIdentityUser, FooIdentityRole>()\r\n    .AddDefaultTokenProviders()\r\n    .AddUserStore<FooUserStore>()\r\n    .AddRoleStore<FooRoleStore>();\r\n```\r\n\r\nThis means that the entire Asp.Net Identity dependencies, including the custom FooUserStore and FooRoleStore, class will be registered on the the default DNX container. Already, this breaks the nice separation between the two containers, but the main issue comes from the AccountController class. Since this class needs access to Asp.Net Identity's UserManager and SignInManager, then it needs to access classes registered on the DNX container.\r\n\r\nWith the suggested integration method, controller activation is completely handled by SimpleInjector through the SimpleInjectorControllerActivator. There is no place to inject DNX registered services from there.\r\n\r\nI thought about registering the Asp.Net Identity types in the DNX container and use SimpleInjector as a forwarder to the DNX's container.\r\n\r\n```csharp\r\ncontainer.Register(app.ApplicationServices.GetRequiredService<UserManager<FooIdentityUser>>)\r\n```\r\n\r\nThe main problem with this solution is that the DNX container now have to know about my data access layer which means more forwarding; and in both direction this time.\r\n\r\nTo me, this feels like a road to hell. I'm sure there must be a simpler way to get this working. What do you recommend to do in this case?"},"comment":{"url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/comments/132779511","html_url":"https://github.com/simpleinjector/SimpleInjector/issues/93#issuecomment-132779511","issue_url":"https://api.github.com/repos/simpleinjector/SimpleInjector/issues/93","id":132779511,"user":{"login":"dotnetjunkie","id":1506621,"avatar_url":"https://avatars.githubusercontent.com/u/1506621?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnetjunkie","html_url":"https://github.com/dotnetjunkie","followers_url":"https://api.github.com/users/dotnetjunkie/followers","following_url":"https://api.github.com/users/dotnetjunkie/following{/other_user}","gists_url":"https://api.github.com/users/dotnetjunkie/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnetjunkie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnetjunkie/subscriptions","organizations_url":"https://api.github.com/users/dotnetjunkie/orgs","repos_url":"https://api.github.com/users/dotnetjunkie/repos","events_url":"https://api.github.com/users/dotnetjunkie/events{/privacy}","received_events_url":"https://api.github.com/users/dotnetjunkie/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T20:49:33Z","updated_at":"2015-08-19T20:49:33Z","body":"> So the solution is pretty much to setup forwarding between the two containers\r\n\r\nYes. There will probably be just a few services where this forwarding is required, although we can expect this will happen more in the future, since every many framework developers will invalidly assume that their framework needs to integrate with the vNext container.\r\n\r\n>  I think you should still post it here if you have some time\r\n\r\nI will. Last days I was quite busy finalizing [v3](https://github.com/simpleinjector/SimpleInjector/releases/tag/v3.0), but no that it is out the door, I'll try to create a SOLID `AccountController` example."}}