Home All Groups Group Topic Archive Search About

WebRequest fails on POST succeeeds on GET

Author
24 Apr 2007 2:43 PM
Lee
Hi,

As the title implies I have a simple WebRequest that works fine doing Gets
to a website but it fails with "The remote server returned an error: (504)
Gateway Timeout". when I tried a POST operation to the same website....here
is a snippet of code I use for the request:

  private static WebResponse FGPostRequest( string uri, string postData )
  {
   ASCIIEncoding encoding = new ASCIIEncoding();
   byte[] postDataBytes = encoding.GetBytes( postData );

   HttpWebRequest request = (HttpWebRequest)WebRequest.Create( uri );
   request.Credentials = CredentialCache.DefaultCredentials;
   request.UserAgent = "SomeClient/" +
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
   request.ContentLength = postDataBytes.Length;
   request.Method = "POST";
   request.ContentType = "application/x-www-form-urlencoded";


   using( System.IO.Stream stream = request.GetRequestStream() )
   {
    stream.Write( postDataBytes, 0, postDataBytes.Length );
   }

   return request.GetResponse();
  }

To clarify it isn't actually me who has the problem it's one of my
customers. The test works fine on my machine, but fails on his.

Any ideas guys?

Regards
Lee

AddThis Social Bookmark Button