"Memo": requestheaders is the cause of header loss when HTTP webrequest is submitted in POST.
Recently, when HttpWebRequest-helper class is completed, Headers are always lost in post json data ).
HttpWebRequest post json data, which consists of the following steps:
> Convert JSON to byte [].
> Get the write stream from HttpWebRequest. GetRequestStream.
> Write byte [] to this Stream.
Similar operations, including file upload and POST form-all must be converted to byte []
Core considerations:
Do not set the HttpWebRequest. ContentLength field. Manually setting this field will lead to the loss of the Header (especially the loss of custom headers ].
I hope that other friends with similar problems will not take detours.
> In the past two days, I have searched more than one hundred webpages for the BUG of header loss, and there is no answer.
> Decompiled the. Net underlying class library to check if Microsoft does not allow custom headers.
> In the end, such a simple line of code is a waste of three days.
Shu Xiaolong InkFx