Customer:
WebClient wc = new WebClient(); try { string json = wc.UploadString("http://localhost:50001/Client/Index", "1"); dynamic receivedData = JsonConvert.DeserializeObject(json); Console.WriteLine("Result: {0};",receivedData.data); } catch (Exception e) { Console.WriteLine("Oh bother"); Console.WriteLine(); Console.WriteLine(e.Message); }
Basically sends a “1” to the Index action in the Client controller.
Here is the controller:
[HttpPost] public ActionResult Index(string k) { Debug.WriteLine(String.Format("Result: {0};", k)); return Json(new { data = k}, JsonRequestBehavior.DenyGet); }
The result of the Client is simply "Result :;". The controller debug output is also "Result :;". This means that data is lost somewhere between the client and the site. But when I debug, Visual Studio says there was one request.
source share