Reputation: 11794
I want to hit a url every 5 mins. I built a c# console app called myconsoleapp.exe and scheduled this in the windows task scheduler:
c#
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.mypage.aspx");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
however I am getting this error? :
Error:
Application: myconsoleapp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Net.WebException Stack: at System.Net.HttpWebRequest.GetResponse() at myconsoleapp.Program.Main(System.String[])
Upvotes: 0
Views: 1686
Reputation: 11209
You might get this error for various reasons such as: - Timeout on web server side - Name not resolving to an IP address - Lack of connectivity to the Internet - Invalid URL - Other network or web site related problems My advices: - Get more info by looking at the error message in the exception - Handle the exception so as to retry upon failure before giving up - Investigate any connectivity, DNS resolution or any other network related problem
Upvotes: 2