Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

HttpConnection
Hi Guys,

I'm using the following code in C# to make an Http Request to a web
site, unfotunitely when I get the request back from the website it
only returns the first 4 characters of the response (which I know
should be much longer than that). I've tried the URL in a web browser
and the response is fine, I've also tried this in Java and again no
problems (ly this has to be in C#, Java will not do).

String parameters = "one=1&two=2";
String post_url = "http://[ipaddress]";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(post_url);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";

//Now we need to read the data length for post
req.ContentLength = parameters.Length;

//POST it
Stream strWrite = req.GetRequestStream();
StreamWriter sw = new StreamWriter(strWrite);
sw.Write(parameters.ToString());
sw.Flush();
sw.Close();

//Read the response back in
WebResponse wr = req.GetResponse();
HttpWebResponse httpRes = (HttpWebResponse)wr;
Stream s = httpRes.GetResponseStream();
StreamReader sr = new StreamReader(s,Encoding.UTF8);
String ret = sr.ReadToEnd();
httpRes.Close();

Console.WriteLine(ret);

Any thoughts, help much appreciated.

Report this thread to moderator Post Follow-up to this message
Old Post
GingerNinja
11-16-04 11:54 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:05 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.