In a C# ASP.NET MVC project, I have an action that receives a Dictionary<string, T>
(T
type is not really important, I think) as a parameter. I also want that parameter to be optional, with a default value of null
.
However, if I don't specify that parameter when calling the action, I get it nonetheless, a dictionary filled with all query string key-value pairs.
The way I understand it, the MVC framework tries to bound the parameter to the query string, and because it is a dictionary with string keys the collection of key-value pairs in the query string is suitable data for the databinding mechanism.
But I need to be able to receive a null
parameter anyway. And I am not allowed to explictly pass null
in the route values either. How could I prevent the query string data binding from happening?