G
Guest
I am posting xml to a server and get the above error returned. The client
code is listed below, it works until say a "<" character is put in XmlData.
On the server page I try to pick up the XmlData with:
Response.Write(Request.Form["XMLData"]);
Client side code:
ASCIIEncoding encoding = new ASCIIEncoding();
string XmlString = "<TEST";
Stream requestStream = null;
string lcUrl = "http://localhost/test/receive.aspx";
HttpWebRequest IoHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
IoHttp.Method = "POST";
IoHttp.ContentType = "application/x-www-form-urlencoded";
byte [] body = encoding.GetBytes("Xml=" +
HttpUtility.UrlEncode(XmlString));
IoHttp.ContentLength = body.Length;
try
{
requestStream = IoHttp.GetRequestStream();
requestStream.Write(body, 0, body.Length);
HttpWebResponse loWebResponse = (HttpWebResponse) IoHttp.GetResponse();
//Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =
new StreamReader(loWebResponse.GetResponseStream());
string lcHtml = loResponseStream.ReadToEnd();
Response.Write (lcHtml);
loWebResponse.Close();
loResponseStream.Close();
}
catch (WebException webexception)
{
}
catch
{
}
finally
{
if (requestStream != null) requestStream.Close();
}
Can anyone see the problem with this?
Thanks
Danny
code is listed below, it works until say a "<" character is put in XmlData.
On the server page I try to pick up the XmlData with:
Response.Write(Request.Form["XMLData"]);
Client side code:
ASCIIEncoding encoding = new ASCIIEncoding();
string XmlString = "<TEST";
Stream requestStream = null;
string lcUrl = "http://localhost/test/receive.aspx";
HttpWebRequest IoHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
IoHttp.Method = "POST";
IoHttp.ContentType = "application/x-www-form-urlencoded";
byte [] body = encoding.GetBytes("Xml=" +
HttpUtility.UrlEncode(XmlString));
IoHttp.ContentLength = body.Length;
try
{
requestStream = IoHttp.GetRequestStream();
requestStream.Write(body, 0, body.Length);
HttpWebResponse loWebResponse = (HttpWebResponse) IoHttp.GetResponse();
//Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =
new StreamReader(loWebResponse.GetResponseStream());
string lcHtml = loResponseStream.ReadToEnd();
Response.Write (lcHtml);
loWebResponse.Close();
loResponseStream.Close();
}
catch (WebException webexception)
{
}
catch
{
}
finally
{
if (requestStream != null) requestStream.Close();
}
Can anyone see the problem with this?
Thanks
Danny