Can someone explain why POST call to the following actions is ambiguous? They have different set of parameters?
[RequireRequestValueAttribute("setID")]
public ActionResult Add(int setID){}
[HttpPost]
public ActionResult Add(TypeModel model, int? queueID) {}
The issue only occurs when using the RequireRequestValueAttribute attribute, which I am using because I wanted to add another method for a Get call with different set of parameters.
Following is the implementation of that that I am using, found on another stackoverflow question:
public class RequireRequestValueAttribute : ActionMethodSelectorAttribute
{
public RequireRequestValueAttribute(string valueName)
{
ValueName = valueName;
}
public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
{
return (controllerContext.HttpContext.Request[ValueName] != null);
}
public string ValueName { get; private set; }
}
OK to answer my own question, it was my stupidity!
My get method has the setID parameter and because it is in the URL, of course this will also be in the post, and therefore RequireRequestValueAttribute was returning TRUE for IsValidForRequest for both methods. I got around it by adding a [HttpGet] attribute to the Get method so things will never get posted to it.