C# application testing connection (ping, download, upload) to the web service

I have created a simple web service that receives data and saves it in a database. I need to create an application (or service) that will test the connection to this web service (from time to time, e.g. every 1 minute).

I need information like download, upload, ping and save them in the database. I tried NetworkInterface, but the web service is not an interface, so it cannot find it. I don’t know how to test this connection and get information about it, so I need help.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Solution 1: fully custom

High level description:

  1. Create a new endpoint , something like api/healthcheck
  2. Either
    a. do a mock action (save/delete false data
    b. Maintain a table or any other persistence (even a singleton would do) with statistics from recent calls
  3. Add them to a class response object and return it to the caller.

Solution 2: Use custom telemetry

High level description:

  1. Pick a service like application insight: https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview
  2. Configure the telemetry if the out of the box configuration isn’t enough.
  3. Use the rest api to get your information


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x