473,795 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Crea te(lcUrl);
IoHttp.Method = "POST";
IoHttp.ContentT ype = "applicatio n/x-www-form-urlencoded";
byte [] body = encoding.GetByt es("Xml=" +
HttpUtility.Url Encode(XmlStrin g));
IoHttp.ContentL ength = body.Length;
try
{
requestStream = IoHttp.GetReque stStream();
requestStream.W rite(body, 0, body.Length);
HttpWebResponse loWebResponse = (HttpWebRespons e) IoHttp.GetRespo nse();

//Encoding enc = System.Text.Enc oding.GetEncodi ng(1252);

StreamReader loResponseStrea m =
new StreamReader(lo WebResponse.Get ResponseStream( ));

string lcHtml = loResponseStrea m.ReadToEnd();

Response.Write (lcHtml);

loWebResponse.C lose();
loResponseStrea m.Close();

}
catch (WebException webexception)
{

}

catch
{

}
finally
{
if (requestStream != null) requestStream.C lose();
}


Can anyone see the problem with this?

Thanks
Danny
Dec 2 '05 #1
1 3092
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.InputSt ream.

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

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

Similar topics

5
10546
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 Text. When posting from the browser a text that is less then about 100K, no errors. When posting more the 100K HTTP 500 - Internal server error Tracing the database - the call to SP was not yet executed.
10
10825
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 the browser, followed by a descriptive error message: Microsoft VBScript runtime error '800a000b' Division by zero followed by the number of the error-making line
5
8481
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
1797
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 independent' machines. I am trying to run Visual Studio 2003, however, the problem occurs before any of this development software (or the CLR) is even installed.
8
10016
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 the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
4
6215
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 pass the data to the web service. I already modified both web.config files and changed maxRequestLength to 60000(kb). When I debug the upload process, it seems the Web application can get the 50M file and read the data without problem, but when the...
4
19975
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: (500) Internal Server Error." I have been searchign the web and followed all the options which worked
4
4888
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 = WebRequest.Create("http://www.ebizautos.com/search-cars/acura-cl-2.2-1997.html"); WebResponse wrs = wr.GetResponse(); Stream strm = wrs.GetResponseStream(); StreamReader SR = new StreamReader(strm); ...
3
5956
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 immediately a IIS 500 Error (Internal Server Error). It is a good thing in production environnement. For debuging purposes, I want temporary to be able to see PHP warnings and errors embedded on the html page.
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10438
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.