Need clean code sample for HttpWebRequest

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
 
G

Guest

J

Joerg Jooss

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top