In handling a form post I have something like
public ActionResult Insert() { Order order = new Order(); BindingHelperExtensions.UpdateFrom(order, this.Request.Form); this.orderService.Save(order); return this.RedirectToAction('Details', new { id = order.ID }); }
I am not using explicit parameters in the method as I anticipate having to adapt to variable number of fields etc. and a method with 20+ parameters is not appealing.
I suppose my only option here is mock up the whole HttpRequest, equivalent to what Rob Conery has done. Is this a best practice? Hard to tell with a framework which is so new.
I’ve also seen solutions involving using an ActionFilter so that you can transform the above method signature to something like
[SomeFilter] public Insert(Contact contact)
I’m now using ModelBinder so that my action method can look (basically) like: