I just installed MVC 5 futures in my solution using Package Manager, but I cannot find this helper method Html.Serialize, which was there in previous MVC Futures releases.
My Question: What namespace I need to include to start using Html.Serialize helper method with MVC 5 Futures?
Apparently, this extension helper is no longer included in the current MVC Futures.
In my case, I replaced the function call Html.Serialize by MvcSerializer.Serialize method which is included in Microsoft.Web.Mvc namespace.
To serialize any object in a hidden field:
@Html.Hidden("otherComplexData", new Microsoft.Web.Mvc.MvcSerializer().Serialize(complexObject))
Later, the controller can turn back the initial object:
[HttpPost]
public ActionResult Index(
IndexViewModel model,
[Deserialize] DataType otherComplexData
)
I hope you find it useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With