Click here to Skip to main content
14,364,458 members
Rate this:
Please Sign up or sign in to vote.
See more:

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;

can you help me what is the proper way of passing a complex type object to controller action



What I have tried:

Used JavascriptSerializer object to serialize the data and send to action
Updated 1-Dec-16 23:03pm
F-ES Sitecore 2-Dec-16 4:09am
Try encoding the json

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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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[^]

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100