{"action":"closed","issue":{"url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/819","labels_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/819/labels{/name}","comments_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/819/comments","events_url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/issues/819/events","html_url":"https://github.com/IdentityServer/Thinktecture.IdentityServer3/issues/819","id":55411933,"number":819,"title":"Injecting IClientStore and MessageCookie<SigninMessage> to MVC controllers","user":{"login":"rklachko","id":4252493,"avatar_url":"https://avatars.githubusercontent.com/u/4252493?v=3","gravatar_id":"","url":"https://api.github.com/users/rklachko","html_url":"https://github.com/rklachko","followers_url":"https://api.github.com/users/rklachko/followers","following_url":"https://api.github.com/users/rklachko/following{/other_user}","gists_url":"https://api.github.com/users/rklachko/gists{/gist_id}","starred_url":"https://api.github.com/users/rklachko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rklachko/subscriptions","organizations_url":"https://api.github.com/users/rklachko/orgs","repos_url":"https://api.github.com/users/rklachko/repos","events_url":"https://api.github.com/users/rklachko/events{/privacy}","received_events_url":"https://api.github.com/users/rklachko/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IdentityServer/Thinktecture.IdentityServer3/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"brockallen","id":649492,"avatar_url":"https://avatars.githubusercontent.com/u/649492?v=3","gravatar_id":"","url":"https://api.github.com/users/brockallen","html_url":"https://github.com/brockallen","followers_url":"https://api.github.com/users/brockallen/followers","following_url":"https://api.github.com/users/brockallen/following{/other_user}","gists_url":"https://api.github.com/users/brockallen/gists{/gist_id}","starred_url":"https://api.github.com/users/brockallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brockallen/subscriptions","organizations_url":"https://api.github.com/users/brockallen/orgs","repos_url":"https://api.github.com/users/brockallen/repos","events_url":"https://api.github.com/users/brockallen/events{/privacy}","received_events_url":"https://api.github.com/users/brockallen/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-01-25T11:45:03Z","updated_at":"2015-01-31T21:33:36Z","closed_at":"2015-01-31T21:33:36Z","body":"In my IDS host I implemented some custom behavior, mainly around \"registration\" and \"forgot my password\" features. I implemented custom user service, custom view service and more. Inside my MVC controllers I want to use the client store, and I want to use the SigninMessage from the cookie.\r\n\r\nBefore the RC release I was able to inject the Client Store by registering it with the MVC container like this:\r\n```\r\nbuilder.Register(c => HttpContext.Current.GetOwinContext().Environment.ResolveDependency<IClientStore>()).AsSelf().InstancePerRequest();\r\n```\r\nBut now the ResolveDependency has became Internal and can't be used like that.\r\n\r\nAbout the SigninMessage. Before the RC I could get it like this:\r\n```\r\nvar cookie = new MessageCookie<SignInMessage>(HttpContext.GetOwinContext().Environment, _options);\r\nvar signInMessage = cookie.Read(model.Signin);\r\n```\r\nBut now I can't do it, because MessageCookie constructors became internal as well.\r\n\r\nWith the latest RC I tried a different way to register it with the MVC container:\r\n```\r\nvar scope = HttpContext.Current.GetOwinContext().Get<ILifetimeScope>(Constants.OwinEnvironment.AutofacScope);\r\nbuilder.Register(c => (IClientStore)scope.Resolve(typeof(IClientStore))).AsSelf().InstancePerRequest();\r\nbuilder.Register(c => (MessageCookie<SignInMessage>)scope.Resolve(typeof(MessageCookie<SignInMessage>))).AsSelf();\r\n```\r\nThis failed with the error: \"No owin.Environment item was found in the context.\"\r\n\r\nI then tried to resolve my needed classes directly inside the controller actions:\r\n```\r\nvar scope = HttpContext.GetOwinContext().Get<ILifetimeScope>(Constants.OwinEnvironment.AutofacScope);\r\nvar signInMessageCookie = (MessageCookie<SignInMessage>)scope.Resolve(typeof(MessageCookie<SignInMessage>));\r\n```\r\nBut some inconsistency with Autofac versions prevents this from working, LifetimeScope from the Owin Context fails to cast to ILifetimeScope.\r\n\r\nAny ideas how to achieve the injection of the ClientStore and MessageCookie (or signin message) to my MVC controllers? A sample would be very helpful.\r\n"}}