Need clean code sample for HttpWebRequest

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Could someone post some clean code for a HTTPS POST request running from a
server to a 3rd party server in an aspx page.
I have some code that works unreliably. If I try the request from a few web
browsers at the same time it will not work reliably.

I use ThreadPool.QueueUserWorkItem, myHttpWebRequest1.BeginGetRequestStream,
myHttpWebRequest1.BeginGetResponse.

Does Microsoft’s .Net SSL socket code use blocking sockets by the way?

If someone could post a sample with how to start the request with a
ThreadPool.RegisterWaitForSingleObject etc so the web page does not return
straight away and some code that can scale to handle many users it would be
appreciated.

Regards
 
Steve said:
Hi,

Could someone post some clean code for a HTTPS POST request running
from a server to a 3rd party server in an aspx page.
I have some code that works unreliably. If I try the request from a
few web browsers at the same time it will not work reliably.

I use ThreadPool.QueueUserWorkItem,
myHttpWebRequest1.BeginGetRequestStream,
myHttpWebRequest1.BeginGetResponse.

Does Microsoft’s .Net SSL socket code use blocking sockets by the
way?

If someone could post a sample with how to start the request with a
ThreadPool.RegisterWaitForSingleObject etc so the web page does not
return straight away and some code that can scale to handle many
users it would be appreciated.

Why do you use ThreadPool.QueueUserWorkItem()? If you use asynchronous
I/O, the request is performed using the CLR thread pool. You can wait
on your IAsyncResult's AsyncWaitHandle.

Cheers,
 
Back
Top