I'm wondering why query string is preferred when getting values from user request. Where? 1) Code of System.Web.Mvc.DefaultModelBinder looks like this (only part of it):
HttpRequestBase request = controllerContext.HttpContext.Request;
if (request != null)
{
if (request.QueryString != null)
{
values = request.QueryString.GetValues(modelName);
attemptedValue = request.QueryString[modelName];
}
if ((values == null) && (request.Form != null))
{
invariantCulture = CultureInfo.CurrentCulture;
values = request.Form.GetValues(modelName);
attemptedValue = request.Form[modelName];
}
}
2) If I have a method in controller with this signature:
public ActionResult Save(int? x, string y) {...
the parameters (x, y) are bound to values from query string, not from form. I would expect that values from Request.From have higher priority than from Request.QueryString.
Edit: I see that the second case is caused by the first one (DefaultModelBinder), am I right?
What's the motivation behind?