如何在 Windows 服务中发出 HTTP 请求? [英] How to make HTTP request in windows service?
本文介绍了如何在 Windows 服务中发出 HTTP 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实现我的第一个 Windows 服务应用程序.这个应用程序必须日夜运行.它应该每 1 小时发送一次 http 请求,并可以对请求的网页进行快照并将其保存在数据库中.
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.
你能告诉我一些 C# 代码示例如何:
can you show me some c# code examples how to:
- 从 Windows 服务发出 http 请求.
- 设置一个计时器,每 1 小时请求一次.
- 发送电子邮件通知快照已成功保存在数据库中.
谢谢!
推荐答案
以下 3 个 MSDN 页面应该可以帮助您入门.
The following 3 MSDN pages should get you started.
- 发出 HTTP 请求:http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx
- 使用计时器:http://msdn.microsoft.com/en-us/library/system.timers.timer(v=VS.100).aspx
- 电子邮件:http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx
这篇关于如何在 Windows 服务中发出 HTTP 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文