Is there a way to force the request router to disambiguate controller actions based on method signatures?
for instance(in a controller):
[HttpPost]
public ActionResult MyAction(FormCollection f) {
//do stuff with big form and return viewresult
return View();
}
[HttpPost]
public JsonResult MyAction(string foo, string bar, bool baz) {
//separate method to handle just the ajax stuff
return Json();
}
I know I can use Request.IsAjaxRequest() in the first method and use that if/then branch to decided my action... but it feels cleaner to leave them separate methods. Not to mention I'd have to cast out the boolean 'baz' (and any other of the non-string types). I have a legitimate reason to use the FormCollection at times or else I'd just keep the JsonResult version around. (the formcollection allows editing of 'many' items while the Json parametrized version just edits a single item)
I could just use different method names too... (probably what I'll do if I can't do what I want)
I tried setting the return type of the 1st method explicitly to ViewResult and ensuring the client sent only accept: application/json headers, but doesn't seem to matter as I keep getting exceptions about the method signatures being ambiguous. Is there a way to force the behavior I want?