Cannot find Html.Serialize helper in MVC 5 futures
Asked Answered
W

1

4

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?

Wolffish answered 13/9, 2014 at 22:59 Comment(0)
E
8

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.

Exocentric answered 28/10, 2014 at 17:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.