Need to PING often from asp.net server during war when electricity is 40% destroyed in Ukraine

Indubhushan 1 Reputation point
2022-11-11T15:28:18.48+00:00

Hello, I live in Kiev, capital of Ukraine. We have biggest war since 2nd world war. During past month, Putin destroyed 40% of electric infrastructure of Ukraine, meaning 4 days of 10 days we have no electricity. In Kyiv here (capital of Ukraine) we have around 10-12 hours when electricity not available. I even was using lift when electricity gone, and had to sit in lift for 1,5 hours.

So I want to make simple asp.net server which can ping my internet provider to see if it is online. usually when electricity is back, it will be here for another few hours. But if there is electricity now for few hours - there is higher risk it will be off soon. So to avoid being stuck in the stopped lift etc, I want to see real times when electricity is working. Best way is to ping my IP address of my home router (which has cable to get internet and gives Wifi).

Please tell me how to make always running program to ping each second. It should not use asp .Net core. I have only asp.net hosting, but I want to make it ping every second (or 5 seconds etc). I can manage myself to save results to mssql-db etc. i just need always running asp.net site (service, maybe webapi?), which will work even if noone visits this website. 

i made a simple button to ping IP. I need to do it automatically like background service. Thank you.

Developer technologies ASP.NET Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Anonymous
    2022-11-14T08:13:54.957+00:00

    Hi @Indubhushan

    Based on your description, if you just want to perform an operation at a fixed time interval, you can use the setInterval(func, delay) function in javascript and send an ajax request to achieve this requirement. Simple code like this below:

    260009-image.png

    260043-image.png
    For code details, please refer to the attachment: 260014-code-simple.txt.
    Best regards,
    Xudong Peng


    If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.