I'm making a request to a remote web server that is currently offline (on purpose).
I'd like to figure out the best way to time out the request. Basically if the request runs longer than "X" milliseconds, then exit the request and return a null
response.
Currently the web request just sits there waiting for a response.....
How would I best approach this problem?
Here's a current code snippet
public JsonpResult About(string HomePageUrl)
{
Models.Pocos.About about = null;
if (HomePageUrl.RemoteFileExists())
{
// Using the Html Agility Pack, we want to extract only the
// appropriate data from the remote page.
HtmlWeb hw = new HtmlWeb();
HtmlDocument doc = hw.Load(HomePageUrl);
HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[@class='wrapper1-border']");
if (node != null)
{
about = new Models.Pocos.About { html = node.InnerHtml };
}
//todo: look into whether this else statement is necessary
else
{
about = null;
}
}
return this.Jsonp(about);
}