Click here to Skip to main content
15,889,865 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I use this code to be able to read a web page content.I don't know what is doing. All I know is that is working for every website I test it.
I have a separate button for this code I provide here, just to initialize something - I presume is the server initialization. After the server initialization is done, after 20 seconds of waiting, I can browse very quickly inside many pages(miliseconds), while the application is open. If the application is closed and re-opened, the same time (20seconds or more) are required to initialization of the server.

But I gave the application to a friend, and he told me that on his computer, the initialization is almost instantaneous.

I think I have a deranged cookie somewhere or something very strange is going on. I use .NET4 for this WINDOWS APPLICATION (not sql or others) with VS2010. In ControlPanel - internet options- advanced- I "reset Internet Explorer Settings" + clean all the cookies,history and the rest from the option provided there. My application is the same as before. I have no idea how to make it go faster like in my friend case.

Any Ideas?
One of my suspicions is related to the lower .NET4 that I use.
Could be because of this cause?

Thank you.

here is the code:
C#
public void PageInit(string adress)
        {
            //Special wepage Reading (extract info from page)
            HttpWebRequest request;
            HttpWebResponse response = null;
            Stream stream = null;
            request = (HttpWebRequest)WebRequest.Create(adress);
            request.UserAgent = "Foo";
            request.Accept = "*/*";
            response = (HttpWebResponse)request.GetResponse();
            stream = response.GetResponseStream();

            StreamReader sr = new StreamReader(stream, System.Text.Encoding.Default);
            string streamx = sr.Peek().ToString();
            if (stream != null) stream.Close();
            if (response != null) response.Close();
        }
Posted
Updated 9-Dec-15 9:03am
v2
Comments
Sergey Alexandrovich Kryukov 9-Dec-15 15:12pm    
How can it be any kind of "service initialization"? You cannot cause such thing by your code. I don't see anything wrong in your code, but it would be more interesting to see what line of it takes the most time. Anyway, I don't think it's any kind of a problem on your client side. And there is no information useful to see what's going on on the server side...
—SA
_Q12_ 9-Dec-15 15:21pm    
Thank you Sergey Alexandrovich Kryukov.
The compiled application, works faster(the server part) on my friend computer than on mine. Probably is a code voodoo to do, or other exterior problem windows related(in this case as you suggested, a service? maybe?)... I have no clue.
What should I look into?
Richard Deeming 9-Dec-15 15:29pm    
Check your DNS settings. It sounds like your primary DNS server is timing out.
_Q12_ 9-Dec-15 15:39pm    
Thank you Richard Deeming.
And how to change it, please?
Thank you very much.
Richard Deeming 9-Dec-15 15:47pm    

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