By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,304 Members | 3,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,304 IT Pros & Developers. It's quick & easy.

500 error when trying to do a post

P: n/a
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(lc PostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Lengt h);
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;
}
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

"Brian" <br*********@msn.com> wrote in message
news:c4*************************@posting.google.co m...
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(lc PostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Lengt h);
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;
}


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.