Question

I am trying do get response from this site(http://www.citizensbank.com/) but i am unable to achieve it. There is an exception saying operation timed out. Even i increase the timeout to 30 mins.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.citizensbank.com");
        request.Timeout = 30000;
        HttpWebResponse response;

        try
        {
            response = (HttpWebResponse)request.GetResponse();

            return response.ResponseUri;
        }

My question is, does the site somehow prevent to get the output.

Était-ce utile?

La solution

If you browse http://www.citizensbank.com you will get redirected to the https version. Trying your code with https works.

That means the website redirects the requests to the secure site.

In most cases the code should work with the redirect since request.AllowAutoRedirect is true by default, but it does not and hangs, that means that probably someone only redirects request from browsers.

This questions shows how to identify redirects, but it does not work for this site.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top