Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys.

I try to read a web page but it does not works.
Here is code from internet:
C#
using System.Net;
using System.IO;
using System.Windows.Forms;

string result = null;
string url = "http://www.devtopics.com";
WebResponse response = null;
StreamReader reader = null;

try
{
 HttpWebRequest request = (HttpWebRequest)WebRequest.Create( url );
 request.Method = "GET";
 response = request.GetResponse();
 reader = new StreamReader( response.GetResponseStream(), Encoding.UTF8 );
 result = reader.ReadToEnd();
}
catch (Exception ex)
{
 // handle error
 MessageBox.Show( ex.Message );
}
finally
{
 if (reader != null)
  reader.Close();
 if (response != null)
  response.Close();
}

I tested with this url http://priceboard.fpts.com.vn/user/stock/hcm3/?s=31&rd=r15332110001
It is a Price Board. Content result is lack of content data.

Help me fix it.
Thanks in advanced!.
Posted
Updated 23-Sep-10 0:10am
v2
Comments
Sandeep Mewara 23-Sep-10 6:11am    
What or where is AJAX in it?

Try this:

C#
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream() );
StringBuilder builder = new StringBuilder();
do
{
    str = reader.ReadLine();
    if (!string.IsNullOrEmpty(str))
    {
        builder.Append(str);
    }
while(str != null);
 
Share this answer
 
Comments
huynhdangthai 23-Sep-10 23:31pm    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
Dear john Simmons
Thank you very much for your replying.
I have test your code and it has the same result with pie of code i gave above.
I saved result to a html file on my hardisk and saw that it is lack of many data from webpage.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900