views:

21

answers:

1

Hi there,

Let's say the Action below is exposed via REST service and is called from a different appliation how would it handle the posted data/object?

Should I use Create(FormCollection collection) here?

[AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Member member) { .... }

+1  A: 

I'd suggest using a model, but one in which all of the parameters are nullable and use the RequiredAttribute for actual, required parameters. This would allow your method to accept invalid requests -- with missing or extra data -- yet have valid data bound to the model. For invalid data, you can supply error returns instead of presuming default values for non-nullable properties. Using the model binding validation architecture provides a convenient way to make sure that the request is legal. It would be up to you how you want to handle "extra" data supplied by the request -- I'd say ignore it.

tvanfosson
Thank you. This is great!
Shuaib