Ответ 1
В вопросе 1: Я бы выполнил POST из .NET-клиента следующим образом. Обратите внимание, что вам нужно будет добавить ссылку на следующие сборки: a) System.Net.Http b) System.Net.Http.Formatting
public static void Post(Testing testing)
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:3471/");
// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
// Create the JSON formatter.
MediaTypeFormatter jsonFormatter = new JsonMediaTypeFormatter();
// Use the JSON formatter to create the content of the request body.
HttpContent content = new ObjectContent<Testing>(testing, jsonFormatter);
// Send the request.
var resp = client.PostAsync("api/test/helloworld", content).Result;
}
Я также переписал бы метод контроллера следующим образом:
[HttpPost]
public string HelloWorld(Testing t) //NOTE: You don't need [FromBody] here
{
return t.Name + " " + t.LastName;
}
В вопросе 2: В Fiddler смените глагол в раскрывающемся списке с GET на POST и введите JSON представление объекта в теле запроса