0

我想每 5 分钟点击一次网址。我构建了名为 myconsoleapp.exe 的 ac# 控制台应用程序,并在 Windows 任务调度程序中安排了它:

C#

static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.mypage.aspx");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        }

但是我收到此错误?:

错误:

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[]) 
4

1 回答 1

2

您可能会因为各种原因收到此错误,例如: - Web 服务器端超时 - 名称未解析为 IP 地址 - 缺乏与 Internet 的连接 - 无效 URL - 其他网络或网站相关问题 我的建议: - 获取更多信息通过查看异常中的错误消息 - 处理异常以便在放弃之前重试失败 - 调查任何连接、DNS 解析或任何其他与网络相关的问题

于 2013-07-01T05:17:05.147 回答