PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
WebResponse Problems
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
WebResponse Problems
![]() |
WebResponse Problems |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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); ============= |
|
|
|
#2 |
|
Guest
Posts: n/a
|
When I try your Url in my web browser, I get back a 404 from the server.
It sounds like you're using the wrong Url in your application. Mike Boilen Developer NET Compact Framework This posting is provided "AS IS" with no warranties, and confers no rights. http://www.gotdotnet.com/team/netcf/FAQ.aspx -------------------- | Content-Class: urn:content-classes:message | From: "Rasika" <dba@iproperty.com.au> | Sender: "Rasika" <dba@iproperty.com.au> | Subject: WebResponse Problems | Date: Sun, 3 Aug 2003 17:12:44 -0700 | Lines: 55 | Message-ID: <02c401c35a1d$20cdb750$a101280a@phx.gbl> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="iso-8859-1" | Content-Transfer-Encoding: 7bit | X-Newsreader: Microsoft CDO for Windows 2000 | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 | Thread-Index: AcNaHSDNP3j4LZ0jTamvUFH5pcJfGQ== | Newsgroups: microsoft.public.dotnet.framework.compactframework | Path: cpmsftngxa06.phx.gbl | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.compactframework:30073 | NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161 | X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework | | | 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); | ============= | |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

