HttpWebRequest and Firewall

G

Guest

Hi

I am trying to POST to a URL using the HTTPWebRequest object
straight forward

ASCIIEncoding encoding = new ASCIIEncoding()
string s = "username=66"

HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create("http://url:8081/sendSMS/SendSMS";)

wreq.Method="POST"

// Set the content type of the data being posted
wreq.ContentType = "application/x-www-form-urlencoded";//"Text/XML"
byte[] byte1 = encoding.GetBytes(s)
wreq.ContentLength = byte1.Length
try{Stream stream = wreq.GetRequestStream()
stream.Write(byte1, 0, byte1.Length)
stream.Close()
WebResponse wresp = wreq.GetResponse()
byte1 = new Byte[wresp.ContentLength]
stream = wresp.GetResponseStream()
stream.Read(byte1, 0, (int)wresp.ContentLength)
stream.Close()
wresp.Close()
String sOut = encoding.GetString(byte1)
Console.WriteLine(sOut)

catch(WebException exWeb)
throw exWeb

catch (Exception e)
throw e


and I keep on gettin
{"The remote server returned an error: (500) Internal Server Error."

I am behind a firewall and have added port 8081 to the ports alowing TCP traffic in both directions

Cheers
 
S

Scott Allen

A500 response sounds like both the request and response are getting
through, so I don't believe this is a firewall issue.

I'd run a utility to watch packets on the network (netmon or tcptrace)
and compare your request to a request from a browser on the same
site. Perhaps the server requires another form variable?
 

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

Top