{"action":"opened","issue":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/3983","labels_url":"https://api.github.com/repos/aspnet/Mvc/issues/3983/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/3983/comments","events_url":"https://api.github.com/repos/aspnet/Mvc/issues/3983/events","html_url":"https://github.com/aspnet/Mvc/issues/3983","id":128502035,"number":3983,"title":"Action with (missing) optional Dictionary param, ModelBinder maps all request params to Dict","user":{"login":"senritsu","id":790689,"avatar_url":"https://avatars.githubusercontent.com/u/790689?v=3","gravatar_id":"","url":"https://api.github.com/users/senritsu","html_url":"https://github.com/senritsu","followers_url":"https://api.github.com/users/senritsu/followers","following_url":"https://api.github.com/users/senritsu/following{/other_user}","gists_url":"https://api.github.com/users/senritsu/gists{/gist_id}","starred_url":"https://api.github.com/users/senritsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senritsu/subscriptions","organizations_url":"https://api.github.com/users/senritsu/orgs","repos_url":"https://api.github.com/users/senritsu/repos","events_url":"https://api.github.com/users/senritsu/events{/privacy}","received_events_url":"https://api.github.com/users/senritsu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-25T10:07:22Z","updated_at":"2016-01-25T10:07:22Z","closed_at":null,"body":"**tldr**\r\nIf an optional dictionary parameter is missing in the request, the ModelBinder tries to cram all other parameters into the dictionary. If the parameter is supplied in the request, even as empty or null value, everything works.\r\n\r\n**Details**\r\n\r\nGiven an action like\r\n```\r\npublic void SomeAction(string foo, string bar, Dictionary<Guid,string> problematicDict = null) {...}\r\n```\r\nany request with a payload of the form\r\n```\r\nfoo = \"something\"\r\nbar = \"something else\"\r\n```\r\nresults in a `System.FormatException`, as the ModelBinder tries to use `foo` and `bar` as dictionary keys with their respective values for `problematicDict`, but the keys are not valid `Guid` representations.\r\n\r\nThis can be further illustrated if the dictionary is changed to accept string keys\r\n```\r\npublic void SomeAction(string foo, string bar, Dictionary<string,string> problematicDict = null) {...}\r\n```\r\nThe same request results in the parameters `foo` and `bar` having the correct values set In addition to that, the dictionary also has a Count of 2, with keys `foo` and `bar` and the values from the request parameters.\r\n\r\n**Workaround**\r\n\r\nIf `problematicDict` is added to the request as a parameter, even with an empty value or `null` as value, everything works just fine. This leads to believe that the default specified in the action is not properly handled."}}