This project is read-only.

Persisting Data after Post

Topics: Customizing Orchard, Troubleshooting, Writing modules
Apr 20, 2011 at 1:14 AM

  I'm having trouble saving data from a view.  A call to TryUpdateModel updates the model just fine during the postback, but it seems to get lost at some point.  When the transaction disposes and tries to save the item, it thinks the properties all have null values.  I can't figure out where the data is getting lost.  Here's the code to handle a post in my controller. 

[HttpPost, ActionName("Create")]
public ActionResult CreatePOST()
   var obj = _myService.CreateMyObject();

   _contentManager.Create(obj, VersionOptions.Draft);
   dynamic model = _contentManager.UpdateEditor(obj, this);

   if (!ModelState.IsValid)
      return View((object)model);


   return Redirect(Url.Item());

Here's my update model code. The call to TryUpdateModel on the controller updates the model with no problems. At some point it gets lost though.

bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties)
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);

Any ideas?? Thanks.