Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code that connects to a php page to check a version, but its always so slow on the first time.
After that it gets the content instantly, anyone know why?

I use:
C#
try
            {
                WebRequest req = WebRequest.Create(URI);
                WebResponse resp = req.GetResponse();
                StreamReader sr = new StreamReader(resp.GetResponseStream());
                return sr.ReadToEnd().Trim();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
Posted
Updated 21-Nov-12 11:34am
v2

1 solution

 
Share this answer
 
Comments
CrispMuffin 21-Nov-12 17:50pm    
I'm still very new to this, how do i get a string of a WebResponse?
wizardzz 21-Nov-12 17:58pm    
You are using a webresponse, and reading it into a StreamReader from a Stream. Calling readtoend() on the StreamReader is returning a string.

You are doing that in these 3 lines of code:
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
CrispMuffin 21-Nov-12 18:08pm    
I got it to work, but it's the same speed, any other things?

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