Need clean code sample for HttpWebRequest

Discussion in 'ASP .Net' started by =?Utf-8?B?U3RldmU=?=, Jun 18, 2005.

  1. 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
    =?Utf-8?B?U3RldmU=?=, Jun 18, 2005
    #1
    1. Advertising

  2. Are you sure there isn't a problem with the third party page?

    This article for the .NET Compact Framework contains
    both a workable .aspx page as well as the http request code.

    http://www.eggheadcafe.com/articles/compactframeworkencryption.asp

    --
    2004 and 2005 Microsoft MVP C#
    Robbe Morris
    http://www.masterado.net

    Earn $$$ money answering .NET Framework
    messageboard posts at EggHeadCafe.com.
    http://www.eggheadcafe.com/forums/merit.asp



    "Steve" <> wrote in message
    news:...
    > 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
    Robbe Morris [C# MVP], Jun 18, 2005
    #2
    1. Advertising

  3. --
    Steve


    "Robbe Morris [C# MVP]" wrote:

    > Are you sure there isn't a problem with the third party page?
    >
    > This article for the .NET Compact Framework contains
    > both a workable .aspx page as well as the http request code.
    >
    > http://www.eggheadcafe.com/articles/compactframeworkencryption.asp
    >
    > --
    > 2004 and 2005 Microsoft MVP C#
    > Robbe Morris
    > http://www.masterado.net
    >
    > Earn $$$ money answering .NET Framework
    > messageboard posts at EggHeadCafe.com.
    > http://www.eggheadcafe.com/forums/merit.asp
    >
    >
    >
    > "Steve" <> wrote in message
    > news:...
    > > 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

    >
    >
    >
    =?Utf-8?B?U3RldmU=?=, Jun 18, 2005
    #3
  4. =?Utf-8?B?U3RldmU=?=

    Joerg Jooss Guest

    Steve wrote:

    > 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,
    --
    http://www.joergjooss.de
    mailto:
    Joerg Jooss, Jun 18, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jake
    Replies:
    0
    Views:
    533
  2. Replies:
    8
    Views:
    500
  3. Steve
    Replies:
    1
    Views:
    132
    Bob Barrows [MVP]
    Jun 17, 2005
  4. Tim Chase
    Replies:
    0
    Views:
    63
    Tim Chase
    Feb 16, 2014
  5. Terry Reedy
    Replies:
    0
    Views:
    70
    Terry Reedy
    Feb 16, 2014
Loading...

Share This Page