如何在 Windows 服务中发出 HTTP 请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4826216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:05:08  来源:igfitidea点击:

How to make HTTP request in windows service?

c#windowswindows-servicesservice

提问by r.r

i want to implement my first windows service application. this app must run day and night. it should to send each 1 hour http request with possibility to make snapshot of requested webpage and save it in database.

我想实现我的第一个 Windows 服务应用程序。这个应用程序必须日夜运行。它应该每 1 小时发送一次 http 请求,并可以制作所请求网页的快照并将其保存在数据库中。

can you show me some c# code examples how to:

你能告诉我一些 C# 代码示例如何:

  1. make http request from windows service.
  2. set a timer for requesting each 1 hour.
  3. send e-mail that snapshot is successfully saved in DB.
  1. 从 Windows 服务发出 http 请求。
  2. 设置一个计时器,每 1 小时请求一次。
  3. 发送电子邮件,快照已成功保存在数据库中。

thank you!

谢谢你!