500 error when trying to do a post

B

Brian

I'm trying to do a POST using the following code, but I'm getting a
500 error. Can somebody please help me? I'm been stuck for quite a
while.


private void bnInvoke_Click(object sender, System.EventArgs e)
{
string lcUrl = "http://www.xmlwebservices.cc/ws/v1/calc/SimpleCalc.asmx/Add";


HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);


// *** Send any POST data

string lcPostData = "a=" + HttpUtility.UrlEncode("4") + "&b=" +
HttpUtility.UrlEncode("5") ;

loHttp.Method="POST";

byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
HttpWebResponse loWebResponse = (HttpWebResponse)
loHttp.GetResponse();

Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();

tbResult.Text = lcHtml;
}
 
K

Ken Cox [Microsoft MVP]

Are you able to get to that page in the browser? I'm getting a 500 error in
IE.

You might want to make sure you have a working Web service before going
further.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top