Client:
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 "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 from the Client
is just "Result: ;". The debug output from the controller is also "Result: ;". This means that the data is lost somewhere between the client and the site. But when I debug, Visual Studio says that there was one request.