request.GetResponse gives always a Timeout

前端 未结 2 1358
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 21:04

I made a Function for a program, which does work when the Request Type is GET, if it is POST, it always produces a Timeout Exception(and the timeout of

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-19 21:46

    So does it hang on req.GetRequestStream() every time, or does it work "a few tries" and then hang?

    If it works a few times and then hangs, it's possible that you're not closing the requests properly, which is causing you to run out of connections. Make sure to Close() and/or Dispose() the HttpWebResponse objects and all of the Streams and Readers that you're creating.

提交回复
热议问题