0
votes

crosspost: https://orchard.codeplex.com/discussions/473252

When updating Content Items back in 1.6, I was able to get field values on POST from the HttpContext like below:

var lat = HttpContext.Current.Request["Latitude"];

Ever since 1.7, those return null and upon inspecting the request, it doesn't have those properties. I checked some more and couldn't find the fields anymore. I even tried injecting the IHttpContextAccessor but still nothing.

Does anyone know where they are held now?

Any piece of advise or information would be highly appreciated, thanks!

1
Why aren't you using model binding?Bertrand Le Roy
These are fields that have been added to the "hidden" part of a Content Item. So I have 3 fields: Latitude, Longitude and MapLink (url of bing maps). I can populate lat and long from the map link provided, so I basically check the POST request if the user did put in lat and long values and if not, I check if the map link is populated and get values from there.AnimaSola
Right. Why aren't you using model binding?Bertrand Le Roy
I actually don't remember why we resorted to hijacking the POST request in 1.6. I have rewritten it to access the values from the parts in the Content Item after the model has been updated. problem solved. Thanks!AnimaSola

1 Answers

1
votes

Do not access post data directly. Use model binding instead. This can be done either with specifically typed and named parameters on a controller action, or through the TryUpdateModel method that is available from driver post methods.