Json 当一个字段包含变音符号时,WebApi FromBody对象为null

Json 当一个字段包含变音符号时,WebApi FromBody对象为null,json,asp.net-web-api,diacritics,Json,Asp.net Web Api,Diacritics,我有一个发布到WebAPI的MVC项目。当使用重音字符(é)时,WebAPI[FromBody]的对象为空。当没有重音字符时,它将正确填充。MVC对象无论如何都是正确的,所以我不知道为什么会出现从JSON到我的API对象的转换问题。JSON由Newtonsoft.JSON.JsonConvert.SerializeObject版本6.0.1生成 using (var client = new HttpClient()) { client.DefaultRequestHeaders.Aut

我有一个发布到WebAPI的MVC项目。当使用重音字符(é)时,WebAPI[FromBody]的对象为空。当没有重音字符时,它将正确填充。MVC对象无论如何都是正确的,所以我不知道为什么会出现从JSON到我的API对象的转换问题。JSON由Newtonsoft.JSON.JsonConvert.SerializeObject版本6.0.1生成

using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _authorizationString);
    string json = Newtonsoft.Json.JsonConvert.SerializeObject(model);

    var response = await client.PostAsync(_url, new StringContent(json, System.Text.Encoding.Default, "application/json"));
    string content = await response.Content.ReadAsStringAsync();
    if (response.IsSuccessStatusCode)
    {
        model = JsonConvert.DeserializeObject<Model>(content);
        TempData["Model"] = model;
        return RedirectToAction("Confirmation");
    }
我还发现了一件事。我可以通过Fiddler成功地发布到API。我从这行复制了JSON,字符串JSON=Newtonsoft.JSON.JsonConvert.SerializeObject(model)


也许PostAsync有错误?

我在PostAsync中切换了编码。Unicode和ASCII都有效。UTF32未显示。

显示控制器操作的代码。
//API
[HttpPost]
public HttpResponseMessage ApiMethod([FromBody] ApiObject obj)
{
    //obj is null here, but only when there is an accent in one of the obj string properties.
    ...
}