request.GetResponse gives always a Timeout

前端 未结 2 1354
爱一瞬间的悲伤
爱一瞬间的悲伤 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.

    0 讨论(0)
  • 2021-02-19 21:50

    You have to use response.Dispose();

    end of the method

    0 讨论(0)
提交回复
热议问题