- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
HttpClient.PostAsync方法的行为是处理提供的HttpContent对象。
有许多方法可以解决此问题,包括为客户端上的每个调用构造一个新的HttpContent
或将内容加载到流中并更改指针。
我想知道为什么调用此方法会自动调用对IDisposable
参数的处理?据我所知,这不是.NET中的常见现象
还要注意的是,在幂等的PUT
请求中也观察到了此行为,因此以防止再次发送信息为前提的前提似乎并不正确。
最佳答案
我无法立即在referencesource上找到实现,但是WCF源也包含它。您要查找的方法是 DisposeRequestContent(HttpRequestMessage)
,附带的注释说明了这一点:
When a request completes,
HttpClient
disposes the request content so the user doesn't have to. This also ensures that aHttpContent
object is only sent once usingHttpClient
(similar toHttpRequestMessages
that can also be sent only once).
HttpContent content = request.Content;
if (content != null)
{
content.Dispose();
}
关于.net - 为什么HttpClient.PostAsync和PutAsync会处理内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25495394/
我有一个后端 Controller 方法 [Route("{ropeId}/segments")] [HttpPut] public async Task Put([NotNull] [FromBod
我正在使用 Apache Ignite Cache 进行事务处理。目前我使用常规的cache.put()方法,但想知道我是否应该更好地使用推荐的putAsync()?如果使用异步方法,Transact
我们有一个第三方 API,它同时具有 GET 和 PUT 方法。第三方 API 仅以 XML 格式返回响应和接受。 api 看起来像 https://bh.org/api/v2/prj/A152 返回
我四处搜索,最终没有找到有关 bluebird 的 promisified 请求的 putAsync 方法的信息。 var request = require('request'); var Prom
在 Controller 上Put如下: [HttpPut] [ActionName("putname")] public JsonResult putname(string name) {
如何创建一个 IHttpContent 对象,其中包含 PutAsync 请求正文的内容? 请求是这样的: IHttpContent myHttpContent = ??? var response
几个小时以来,我一直在努力找出问题所在,但就是找不到问题所在。 通过 Mvc 应用程序,put 方法不会被命中,请求不会发生。但是当我在 fiddler 中测试它时,api 中的 PutMethod
我有一个可以完美发布数据的POST方法。 查看文档似乎 PATCH(或 PUT)应该看起来完全一样,只需使用 PutAsync 而不是 PostAsync。 好吧,我收到以下错误: + p
我是一名优秀的程序员,十分优秀!