G
GHS
I have some code to connect to a website and pull some content out of the
HTML. I've verified that the 2 URLs I'm using are perfectly fine in
Internet Explorer and both of them return results "pretty quickly".
The first URL I try takes a while but eventually comes back with the correct
results. It took *much longer* than in Internet Explorer.
The second URL times out even if I increase the timeout value significantly.
Internet explorer didn't time out.
The first URL simply visits the main page.
The second URL is attempting to login (http - not https).
Any idea what might be wrong? I'll post my code below.
private string GetHTTP(string url)
{
string html;
HttpWebRequest req;
HttpWebResponse resp;
// Formulate the request
//
req = (HttpWebRequest)WebRequest.Create(url);
req.CookieContainer = new CookieContainer();
if (m_cookies != null && m_cookies.Count > 0)
{
// Add any previously saved cookies
//
req.CookieContainer.Add(m_cookies);
}
// Get the response
//
resp = (HttpWebResponse)req.GetResponse();
if (resp.Cookies.Count > 0)
{
// Save off cookies for later use
//
m_cookies = resp.Cookies;
}
// Read the result
//
html = new StreamReader(resp.GetResponseStream(),
Encoding.Default).ReadToEnd();
resp.Close();
return html;
}
and then calling it with:
// Visit the site - sets up the initial cookies
//
// note: "http://www.warhorn.net/gilacon/"
// This takes much longer than Internet Explorer
html = GetHTTP(InitialURL);
// Login to the site
//
// note:
"http://www.warhorn.net/gilacon/login.do?WH_loginUsername=YYYYY&WH_loginPassword=XXXXX"
// This times out - even if I bump up the timeout value.
html = GetHTTP(LoginURL);
Notes:
Upon a succesful login (2nd URL) in Internet Explorer, it is redirected
to a different URL. I'm assuming the timeout is because of that somehow.
If you want to experiment with the existing site, feel free to create an
account (it's for an event which is over already).
Ideas/suggestions?
--GHS
HTML. I've verified that the 2 URLs I'm using are perfectly fine in
Internet Explorer and both of them return results "pretty quickly".
The first URL I try takes a while but eventually comes back with the correct
results. It took *much longer* than in Internet Explorer.
The second URL times out even if I increase the timeout value significantly.
Internet explorer didn't time out.
The first URL simply visits the main page.
The second URL is attempting to login (http - not https).
Any idea what might be wrong? I'll post my code below.
private string GetHTTP(string url)
{
string html;
HttpWebRequest req;
HttpWebResponse resp;
// Formulate the request
//
req = (HttpWebRequest)WebRequest.Create(url);
req.CookieContainer = new CookieContainer();
if (m_cookies != null && m_cookies.Count > 0)
{
// Add any previously saved cookies
//
req.CookieContainer.Add(m_cookies);
}
// Get the response
//
resp = (HttpWebResponse)req.GetResponse();
if (resp.Cookies.Count > 0)
{
// Save off cookies for later use
//
m_cookies = resp.Cookies;
}
// Read the result
//
html = new StreamReader(resp.GetResponseStream(),
Encoding.Default).ReadToEnd();
resp.Close();
return html;
}
and then calling it with:
// Visit the site - sets up the initial cookies
//
// note: "http://www.warhorn.net/gilacon/"
// This takes much longer than Internet Explorer
html = GetHTTP(InitialURL);
// Login to the site
//
// note:
"http://www.warhorn.net/gilacon/login.do?WH_loginUsername=YYYYY&WH_loginPassword=XXXXX"
// This times out - even if I bump up the timeout value.
html = GetHTTP(LoginURL);
Notes:
Upon a succesful login (2nd URL) in Internet Explorer, it is redirected
to a different URL. I'm assuming the timeout is because of that somehow.
If you want to experiment with the existing site, feel free to create an
account (it's for an event which is over already).
Ideas/suggestions?
--GHS