473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Remote server returns (500) Internal Server Error,when posting xml

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
Dec 2 '05 #1
1 3038
Danny wrote:
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"]);


ASP.NET does not allow form data containing certain characters used in
injection attacks by default . You can disable this feature using the
page directive ValidateRequest="false", but a better approach is to
post the XML "as is", and not as form data. See
http://tinyurl.com/b8al3 for a sample.

On the server-side, read the XML directly from Request.InputStream.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Dec 3 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Moshe | last post by:
Scenario - IIS 5.0 WIN2K latest SP Application ASP. An ASP Page has a text area. When submitted calls SQL server 2K Stored Procedure to update a record. The field in the data base is of type...
10
by: | last post by:
I am accessing the same error-containing ASP page on an ISP server using w2k IE6 but with different effect. On the first computer I get several line of HTML outputed by ASP, shown correctly by...
5
by: Ben | last post by:
hi when I try to excecute an ASP (either JS or VB) script to say, access a database record, I get an Internal Server Error HTTP 500.100 Why? and HOW CAN I FIX THIS? Thanks
6
by: Damien Sawyer | last post by:
Hello - I'm having a serious problem with IIS on Windows XP pro. Whenever I try to run ASP pages, I get HTTP 500 - Internal server error This behaviour happens identically, on two 'totally...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
4
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and...
4
by: kuladeep.mohan | last post by:
Hi I am trying to consume a web service from asp.net web page through HTTP POST method and I am getting the following error message "System.Net.WebException: The remote server returned an error:...
4
by: Barnali85 | last post by:
Hi all, I am getting "The remote server returned an error: (500) Internal Server Error" exception. I have written the following code in VS.NET2005 using C# : WebRequest wr =...
3
by: guillaume.braux | last post by:
Hello, I am running WS2008 + IIS7 + FASTCGI + ZendCore. I have not modified the default ZendCore php.ini configuration file. Actualy, any kind of PHP error, warning or notice gives me...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.