简体   繁体   中英

Calling website through Windows Service

Looking at creating a windows service that will run on an IIS Server. Said service will access an url (mysite.com/mailflow.ashx) every 5 minutes. This is done to get the mailflow going, which is done by accessing the mailflow.ashx file.

Is: https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx what I'm looking for in my scenario or is there another class that will do the job?

Coming from a non-coding background but I want to do this on my own as a learning experience.

Small hints are more than enough.

Cheers!

Unless you really want to learn coding, I'd recommend simply creating a scheduled task in windows. Make it call the following js script (called wget in my case)

var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false);
WinHttpReq.Send();
WScript.Echo(WinHttpReq.ResponseText);

and set the task to start the following program cscript with the following arguments /nologo C:\\Path\\To\\wget.js http://my.url.com

There are plenty of ways to ping an remote url, so you may decide to use another option (perhaps simply launching then killing a browser) but coding a service really is overkill if this is the only task you need

是的,您需要HttpWebRequest类。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM