开发者

c# and WebRequest: change contentlenght

开发者 https://www.devze.com 2023-02-13 10:09 出处:网络
I\'ve to send some post to a server, so i create a webrequest set the method, the content type and the content lenght. It works ok.

I've to send some post to a server, so i create a webrequest set the method, the content type and the content lenght. It works ok. Now I want to send a sec开发者_如何学运维ond post so I need to change the contentlenght but I give an exception and i don't understand why.


You haven't told us the error details, but I suspect the first request has not yet completed. IMO, unless you are doing something particularly subtle, it is often a good idea to use WebClient, which is a wrapper around WebRequest (etc) that greatly simplifies the API - for example you can just call the UploadData method, or DownloadString, etc. These are easy to call successively.

0

精彩评论

暂无评论...
验证码 换一张
取 消