How can I overload actions in ASP.NET MVC, but with support for GET QueryString? I tried to do something like this:
public JsonResult Find(string q)
{
...
}
public JsonResult Find(string q, bool isBlaBla)
{
...
}
But whenever I access /controller/find?q=abc or /controller/find?q=abc&isBlaBla=false it throws anSystem.Reflection.AmbiguousMatchException.
How to fix this?
You actually don’t need to create overloads. All you need to do is create a single action method with all the possible arguments that you expect and it will map the values (where possible) for you.
You could even make use of Optional Parameters and Name Arguments if you’re using C# 4.0