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:
public void PageInit(string adress)
{
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();
}