문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top