R
Rasika
Hello
I am trying to connect to our web server to send a http
post. However I get the Exception below thrown.
------
An unhandled exception of type 'System.Net.WebException'
occurred in System.dll
Additional information: The remote server returned an
error: (404) Not Found.
------
I have checked the url and it opens fine. I cant figure
out what I am doing wrong. Please help!
Rasika
=============
String xml = GetXml();
WebRequest request;
WebResponse response;
StreamReader streamReader;
Stream stream;
Byte[] buffer;
request = WebRequest.Create
("http://server.com/xml/uploads/Default.aspx");
//*** Do i need a question mark here
buffer = Encoding.UTF8.GetBytes("?xml=" + xml);
request.Method = "post";
//*** Is this the correct mime type?
request.ContentType = "text/html";
request.ContentLength = buffer.Length;
stream = request.GetRequestStream();
stream.Write(buffer, 0, buffer.Length);
stream.Close();
response = request.GetResponse();
//*** This is where the Exception is thrown
streamReader = new StreamReader(response.GetResponseStream
());
String responseHtml = streamReader.ReadToEnd();
streamReader.Close();
response.Close();
MessageBox.Show(responseHtml);
=============
I am trying to connect to our web server to send a http
post. However I get the Exception below thrown.
------
An unhandled exception of type 'System.Net.WebException'
occurred in System.dll
Additional information: The remote server returned an
error: (404) Not Found.
------
I have checked the url and it opens fine. I cant figure
out what I am doing wrong. Please help!
Rasika
=============
String xml = GetXml();
WebRequest request;
WebResponse response;
StreamReader streamReader;
Stream stream;
Byte[] buffer;
request = WebRequest.Create
("http://server.com/xml/uploads/Default.aspx");
//*** Do i need a question mark here
buffer = Encoding.UTF8.GetBytes("?xml=" + xml);
request.Method = "post";
//*** Is this the correct mime type?
request.ContentType = "text/html";
request.ContentLength = buffer.Length;
stream = request.GetRequestStream();
stream.Write(buffer, 0, buffer.Length);
stream.Close();
response = request.GetResponse();
//*** This is where the Exception is thrown
streamReader = new StreamReader(response.GetResponseStream
());
String responseHtml = streamReader.ReadToEnd();
streamReader.Close();
response.Close();
MessageBox.Show(responseHtml);
=============