Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请移除 Microsoft.AspNet.WebApi.Client 的引用,该库在 Core 3.1 下无法正常工作。 #2178

Closed
7 of 29 tasks
hetaoos opened this issue May 11, 2020 · 2 comments
Closed
7 of 29 tasks

Comments

@hetaoos
Copy link
Contributor

hetaoos commented May 11, 2020

此版块专为反馈 bug 及提交需求服务,不负责解答开发问题,请勿发表开发问题,
如果您需要这方面的帮助,请移步问答社区https://weixin.senparc.com/QA

问题描述

在 dotnet core 3 中,如果使用 Microsoft.AspNet.WebApi.Client 并使用 HttpClientPostAsJsonAsync 扩展方法,Post 到服务端的数据不正确。

简单示例代码:

var client = new HttpClient();
var d = new { i = 0, t = 99 };
await client.PostAsJsonAsync("http://127.0.0.1", d);

服务端收到的数据是这样的:

POST / HTTP/1.1
Host: 127.0.0.1
Transfer-Encoding: chunked
Content-Type: application/json; charset=utf-8

E
{"i":0,"t":99}
0

类似问答

该库已经很老了,已经不适用于 dotnet core 3.1,劳烦请移除。

重现问题步骤(如果可以)
  1. ...
  2. ...
微信官方文档 URL
微信官方文档快照(直接复制关键内容到下方)
发现问题的模块
  • Senparc.Weixin 版本:
  • Senparc.Weixin.MP 版本:
  • Senparc.Weixin.MP.MVC 版本:
  • Senparc.Weixin.Open 版本:
    - [ ] Senparc.Weixin.QY 版本:
  • Senparc.Weixin.Work 版本:
  • Senparc.Weixin.WxOpen 版本:
  • Senparc.Weixin.Cache.Redis 版本:
  • Senparc.Weixin.Cache.Memcached 版本:
  • 其他模块:
模块对应的 .net 版本
  • .net 3.5
  • .net 4.0
  • .net 4.5
  • .net standard 2.0
  • .net core 1.x
  • .net core 2.x
  • .net core 3.x
开发环境
  • Visual Studio 2015
  • Visual Studio 2017
  • Visual Studio 2019
  • Visual Studio Code
  • 其他:
缓存环境
  • 服务器内存缓存(默认)
  • Redis 版本:
  • Memcached 版本:
  • 其他:
系统环境
  • Windows,版本:
  • Linux,版本:
  • Mac,版本:
  • 其他:
联系方式

Email:

(也可将问题地址及联系方式发送到 www.jeffrey.su@gmail.com)

发布问题后,请保持对 issue 的关注,有时会有需要进一步沟通的信息,很长时间内没有得到答复的 issue 将被关闭。

@hetaoos
Copy link
Contributor Author

hetaoos commented May 11, 2020

我自己实现了个同名的扩展方法

public static Task<HttpResponseMessage> PostAsJsonAsync<T>(this HttpClient client, string requestUri, T value, CancellationToken cancellationToken = default)
            => client.PostAsync(requestUri, new StringContent(JsonConvert.SerializeObject(value), encoding, "application/json"), cancellationToken);

但,引用了 Microsoft.AspNet.WebApi.Client 后,被覆盖了。。。

@JeffreySu
Copy link
Owner

@hetaoos 这个库目前没有实际用到,我发布了一个新版本的CO2NET,您可以先只更新这个库试一下(其他SDK等库应该都没用到):http://nuget.org/packages/Senparc.CO2NET

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants