将复杂对象从代码隐藏(.aspx.cs)传递到控制器操作方法 [英] Passing complex object from codebehind (.aspx.cs) to controller action method
本文介绍了将复杂对象从代码隐藏(.aspx.cs)传递到控制器操作方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过操作Url和querystring从aspx页面的代码隐藏调用控制器操作。我在添加到操作URL查询字符串之前序列化了对象。复杂对象的值在运行时的动作调用上返回null。
Hi,
I am calling a controller action from codebehind of aspx page by action Url with querystring. I serialized the object before adding into the action URL querystring. The value of complex object returns null on action call in runtime.
framePdf.Src ="http://localhost:56336/Home/Test?pdfData=" + jsonString;
你能帮我解决传递复杂类型对象的正确方法吗?控制器动作
问候
Gopi
我尝试过:
使用JavascriptSerializer对象序列化数据并发送到行动
can you help me what is the proper way of passing a complex type object to controller action
Regards
Gopi
What I have tried:
Used JavascriptSerializer object to serialize the data and send to action
推荐答案
将数据从一个代码发布到控制器的一种方法是这样的:HttpWebRequest.BeginGetRequestStream Method(System.Net) [ ^ ]
控制序列化如果您的对象太复杂而无法进行自动序列化,那么您最好使用自定义JsonConverter [ ^ ]
One way to post data from one code behind to a controller is like this: HttpWebRequest.BeginGetRequestStream Method (System.Net)[^]
To control serialization if your object is too complex for automatic serialization you'd be well advice to use something like this Custom JsonConverter[^]
这篇关于将复杂对象从代码隐藏(.aspx.cs)传递到控制器操作方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文