1

I'm using a third party url to determine the location of site visitors based on IP address.

I use WebClient.DownloadData() to get the information returned by the url which is a one word answer e.g. as per http://api.hostip.info/country.php

Once I have detected what country the user is in I want to either A) keep them on the current site and store the country in the session or B) redirect them to another countries site.

What I'm worried about is WebClient.DownloadData() hanging so the user is waiting for ages and can't use the site. I'd thought about using DownloadDataAsync but this dosn't seem to be a solution for me as I don't want them to do anything till I find out the country (also see WebClient.DownloadDataAsync is freezing my UI)

Is there a way I can set a timelimit on my call to WebClient.DOwnloadData e.g. if it hasn't returned in 2 seconds, give up?

1

1 Answer 1

2

Looks like HttpWebRequest may be the way to go

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.