Click here to Skip to main content
15,902,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.


C#
framePdf.Src ="http://localhost:56336/Home/Test?pdfData=" + jsonString;




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
Posted
Updated 1-Dec-16 22:03pm
Comments
F-ES Sitecore 2-Dec-16 4:09am    
Try encoding the json

framePdf.Src ="http://localhost:56336/Home/Test?pdfData=" + encodeURIComponent(jsonString);

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900