C# 期望:100-继续

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15341287/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 16:28:47  来源:igfitidea点击:

Expect: 100-continue

c#httppost

提问by Hikiko

There are a lot of questions on this topic, but - they gave me no answer.

关于这个话题有很多问题,但是 - 他们没有给我答案。

As from advices - there is one to set ServicePointManager.Expect100Continue = false. But it is not acceptable because this will be a module, asynchroniously working along with dozen of others. So acceptable solution - is per-connection property. There are advices how to set this, but it doesn't seem to be working.

根据建议 - 有一个要设置ServicePointManager.Expect100Continue = false。但这是不可接受的,因为这将是一个模块,与其他十几个异步工作。所以可接受的解决方案 - 是每个连接属性。有一些建议如何设置它,但它似乎不起作用。

Here is the code:

这是代码:

var conuri = new Uri(connectionString);
var sp = ServicePointManager.FindServicePoint(conuri);
sp.Expect100Continue = false;

_request = (HttpWebRequest)WebRequest.Create(conuri);
_request.ContentType = "text/xml";
_request.Method = "POST";

_request.ContentLength = dataToSend.Length;
requestStream = _request.GetRequestStream();
requestStream.Write(dataToSend, 0, dataToSend.Length);

Problem is, that at the point "requestStream.Write" - header Expect: 100-continueis still added, but it shouldn't according to advice I've read here: C# Expect100Continue header request.

问题是,在这一点上,“requestStream.Write” -Expect: 100-continue仍然添加了标头,但它不应该根据我在这里阅读的建议:C# Expect100Continue header request

采纳答案by Parimal Raj

You can do it this way :

你可以这样做:

_request.ServicePoint.Expect100Continue = false;

This will disable the Expect: 100-continuefor a particular HttpWebRequestinstance.

这将禁用Expect: 100-continue特定HttpWebRequest实例的 。