I have a requirement where the Asp.Net Core Application(Deployed to IIS) needs to send data external domain("http://example.com/api/statistics") at a given time everyday(only once a day; say 6PM localTime where application is running). I am hesitant to place code any place(like in Startup.cs or Program.cs) that might create problems later. Something like the following : Your insights highly appreciated. Thank you.
Task.Run(() =>
{
while (true)
{
using (var client = new HttpClient())
{
var response = client.PostAsync("http://example.com/api/statistics",
new StringContent(JsonConvert.SerializeObject("data"),
Encoding.UTF8, "application/json"));
}
}
});