{"action":"created","issue":{"url":"https://api.github.com/repos/autofac/Autofac/issues/652","labels_url":"https://api.github.com/repos/autofac/Autofac/issues/652/labels{/name}","comments_url":"https://api.github.com/repos/autofac/Autofac/issues/652/comments","events_url":"https://api.github.com/repos/autofac/Autofac/issues/652/events","html_url":"https://github.com/autofac/Autofac/issues/652","id":91351385,"number":652,"title":"DNX: Configuration done against lifetime scope is not compatible with MVC","user":{"login":"vossad01","id":965439,"avatar_url":"https://avatars.githubusercontent.com/u/965439?v=3","gravatar_id":"","url":"https://api.github.com/users/vossad01","html_url":"https://github.com/vossad01","followers_url":"https://api.github.com/users/vossad01/followers","following_url":"https://api.github.com/users/vossad01/following{/other_user}","gists_url":"https://api.github.com/users/vossad01/gists{/gist_id}","starred_url":"https://api.github.com/users/vossad01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vossad01/subscriptions","organizations_url":"https://api.github.com/users/vossad01/orgs","repos_url":"https://api.github.com/users/vossad01/repos","events_url":"https://api.github.com/users/vossad01/events{/privacy}","received_events_url":"https://api.github.com/users/vossad01/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-26T20:13:56Z","updated_at":"2015-07-27T14:18:26Z","closed_at":"2015-07-27T14:18:26Z","body":"I have been trying to component-ize part of an ASP.NET 5 application.  Once my code was in place I found my MVC Web Services to always return HTTP 406 (Not acceptable).  I have finally narrowed down the issue to doing the registration \"late\" on an Autofac Lifetime Scope.\r\n\r\nThis is how I would like my registration to be, but does causes the 406:\r\n```\r\napp.Map(\r\n    \"/comp\",\r\n    c =>\r\n        {\r\n            ILifetimeScope lifetimeScope =\r\n                c.ApplicationServices.GetRequiredService<ILifetimeScope>().BeginLifetimeScope(\r\n                    cb =>\r\n                        {\r\n                            var sc = new ServiceCollection();\r\n                            sc.AddMvc();\r\n\r\n                            cb.Populate(sc);\r\n                        });\r\n\r\n            c.ApplicationServices = lifetimeScope.Resolve<IServiceProvider>();\r\n\r\n            c.UseMvc();\r\n        });\r\n```\r\nUsing `ContainerBuilder.Update` on a new LifetimeScope rather than the lambda exhibits the same issue.  However update on the original container allows the services to work, but unfortunately does not isolate the the MVC dependencies.\r\n\r\n```\r\napp.Map(\r\n    \"/comp\",\r\n    c =>\r\n        {\r\n            ILifetimeScope lifetimeScope = c.ApplicationServices.GetRequiredService<ILifetimeScope>();\r\n\r\n            var builder = new ContainerBuilder();\r\n            var sc = new ServiceCollection();\r\n            sc.AddMvc();\r\n            builder.Populate(sc);\r\n            builder.Update(lifetimeScope.ComponentRegistry);\r\n\r\n            c.ApplicationServices = lifetimeScope.Resolve<IServiceProvider>();\r\n\r\n            c.UseMvc();\r\n        });\r\n```\r\n\r\nIn general re-assigning the `ApplicationServices` does work, as can be shown why storing the original IServiceCollection from `ConfigureServices` and creating a new `IServiceProvider`.\r\n\r\n```\r\napp.Map(\r\n    \"/comp\",\r\n    c =>\r\n        {\r\n            var services = new ServiceCollection();\r\n            foreach (var service in this._services)\r\n            {\r\n                services.Add(service);\r\n            }\r\n            services.AddMvc();\r\n            c.ApplicationServices = services.BuildServiceProvider();\r\n            c.UseMvc();\r\n        });\r\n```\r\n\r\n4.0.0-alpha2"},"comment":{"url":"https://api.github.com/repos/autofac/Autofac/issues/comments/125222497","html_url":"https://github.com/autofac/Autofac/issues/652#issuecomment-125222497","issue_url":"https://api.github.com/repos/autofac/Autofac/issues/652","id":125222497,"user":{"login":"tillig","id":1156571,"avatar_url":"https://avatars.githubusercontent.com/u/1156571?v=3","gravatar_id":"","url":"https://api.github.com/users/tillig","html_url":"https://github.com/tillig","followers_url":"https://api.github.com/users/tillig/followers","following_url":"https://api.github.com/users/tillig/following{/other_user}","gists_url":"https://api.github.com/users/tillig/gists{/gist_id}","starred_url":"https://api.github.com/users/tillig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillig/subscriptions","organizations_url":"https://api.github.com/users/tillig/orgs","repos_url":"https://api.github.com/users/tillig/repos","events_url":"https://api.github.com/users/tillig/events{/privacy}","received_events_url":"https://api.github.com/users/tillig/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T14:18:26Z","updated_at":"2015-07-27T14:18:26Z","body":"This appears to be a duplicate with #659."}}