{"action":"created","issue":{"url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/7","repository_url":"https://api.github.com/repos/autofac/Autofac.WebApi","labels_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/7/comments","events_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/7/events","html_url":"https://github.com/autofac/Autofac.WebApi/issues/7","id":104918575,"number":7,"title":"Can't add multiple filters to the same controller","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},"labels":[{"url":"https://api.github.com/repos/autofac/Autofac.WebApi/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/autofac/Autofac.WebApi/labels/module-integration-webapi","name":"module-integration-webapi","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2015-09-04T15:57:00Z","updated_at":"2016-08-03T21:19:19Z","closed_at":"2016-08-03T21:19:19Z","body":"_From @taschmidt on October 15, 2014 13:53_\n\nGiven this code:\r\n\r\n```\r\n    builder.RegisterType<FilterA>().AsWebApiExceptionFilterFor<MyController>().InstancePerRequest();\r\n    builder.RegisterType<FilterB>().AsWebApiExceptionFilterFor<MyController>().InstancePerRequest();\r\n```\r\n\r\nI get the following exception:\r\n\r\n```\r\n[ArgumentException: An item with the same key has already been added.]\r\n   System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +14874155\r\n   Autofac.Builder.RegistrationBuilder`3.WithMetadata(String key, Object value) +38\r\n   Autofac.Integration.WebApi.RegistrationExtensions.AsFilterFor(IRegistrationBuilder`3 registration, String metadataKey) +294\r\n   ...\r\n```\r\n\r\nWe should definitely have the ability to register multiple filters on the same controller.\r\n\n\n_Copied from original issue: autofac/Autofac#586_"},"comment":{"url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/comments/237377385","html_url":"https://github.com/autofac/Autofac.WebApi/issues/7#issuecomment-237377385","issue_url":"https://api.github.com/repos/autofac/Autofac.WebApi/issues/7","id":237377385,"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":"2016-08-03T21:19:19Z","updated_at":"2016-08-03T21:19:19Z","body":"I'm not currently able to reproduce this using the 3.4.0 version of the code. I explicitly put a test together with some test types that looks like this:\r\n\r\n``` csharp\r\n        [Fact]\r\n        public void MultipleExceptionFiltersOnOneController()\r\n        {\r\n            var builder = new ContainerBuilder();\r\n            builder.Register<ILogger>(c => new Logger()).InstancePerDependency();\r\n            builder.RegisterType<TestExceptionFilter>().AsWebApiExceptionFilterFor<TestController>();\r\n            builder.RegisterType<TestExceptionFilter2>().AsWebApiExceptionFilterFor<TestController>();\r\n            var container = builder.Build();\r\n            var provider = new AutofacWebApiFilterProvider(container);\r\n            var configuration = new HttpConfiguration { DependencyResolver = new AutofacWebApiDependencyResolver(container) };\r\n            var actionDescriptor = BuildActionDescriptorForGetMethod();\r\n\r\n            var filterInfos = provider.GetFilters(configuration, actionDescriptor).ToArray();\r\n\r\n            var wrapperType = GetWrapperType();\r\n            var filters = filterInfos.Select(info => info.Instance).Where(i => i.GetType() == wrapperType).ToArray();\r\n            Assert.Equal(1, filters.Length);\r\n            Assert.IsType(wrapperType, filters[0]);\r\n        }\r\n```\r\n\r\nWe actually already have unit tests for multiple controllers per filter on all the filter types (so I don't need to keep this one-off, but I just wanted to manually verify).\r\n\r\nI'm going to close this guessing that it was fixed sometime between the 3.2.1 version and now. If things are failing, upgrade to the latest.\r\n\r\nIf you can still repro this with the latest stable bits, please post that repro somewhere and let us know so we can re-open the issue."}}
{"actor":{"display_login":"tillig"}}