找不到MVC 5期货Html.Serialize帮手 [英] Cannot find Html.Serialize helper in MVC 5 futures

查看:259
本文介绍了找不到MVC 5期货Html.Serialize帮手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚安装了MVC中使用软件包管理器我的解决方案5期货,但我不能找到这个helper方法 Html.Serialize ,这是那里previous MVC期货版本。

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.

我的提问:我需要空间,包括中开始使用MVC 5期货交易Html.Serialize helper方法

My Question: What namespace I need to include to start using Html.Serialize helper method with MVC 5 Futures?

推荐答案

显然,这扩展帮助不再包含在当前的MVC期货。

Apparently, this extension helper is no longer included in the current MVC Futures.

在我而言,我换成了函数调用Html.Serialize <一个href=\"http://msdn.microsoft.com/en-us/library/microsoft.web.mvc.mvcserializer.serialize(v=vs.118).aspx\"相对=nofollow> MvcSerializer.Serialize 方法巫婆包含在Microsoft.Web.Mvc命名空间。

In my case, I replaced the function call Html.Serialize by MvcSerializer.Serialize method witch 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.

这篇关于找不到MVC 5期货Html.Serialize帮手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆