public async Task <IActionResult> SendHttpFormContent() { //sample /* * "col1":"val1" * "col2":"1" * "colList[0][sub1]":"v1" * "colList[0][sub2]":"11" * "colList[0][subList][0][sub1]":"sub1" * "colList[0][subList][0][sub2]":"111" * "colList[1][sub1]":"v2" * "colList[1][sub2]":"12" * * "col1","val1" * "col2","1" * "colList[0][sub1]","v1" * "colList[0][sub2]","11" * "colList[0][subList][0][sub1]","sub11" * "colList[0][subList][0][sub2]","111" * "colList[1][sub1]","v22" * "colList[1][sub2]","12" */ var model = new MTest1(); model.col1 = "val1"; model.col2 = 1; model.colList = new List <MSubTest1>(); var sub = new MSubTest1() { sub1 = "v1", sub2 = 11 }; sub.subList = new List <MSubTest1>(); sub.subList.Add(new MSubTest1() { sub1 = "sub11", sub2 = 111 }); model.colList.Add(sub); model.colList.Add(new MSubTest1() { sub1 = "v22", sub2 = 12 }); using (var client = new HttpClientHelper()) { var r = await client.SendMultipartAsync(HttpMethod.Post, "http://localhost:5000/Lab/GetFormContentTest", model, null); return(Content(r, "text/json")); } }
public IActionResult GetFormContentTest(MTest1 input) { /* * var list = new List<KeyValuePair<string, string>>(); * foreach(var item in Request.Form) * { * list.Add(new KeyValuePair<string, string>(item.Key, item.Value)); * } */ return(Json(new { text1 = JsonConvert.SerializeObject(input) }));; }