I realized simple healthcheck in my site. I need to know, is connection to database ok or not. For this I want to ping it. How to ping database from api controller code?
if your db connection is not correct umbraco will not work, you will get an error trying to access it, so if you are in umbraco then your dbis working.
a ping will only tell you if the server is up or not, not whether something running on the server is running.
Did you try turning of the db and then trying to load umbraco? it won't load if the database is not active. So not sure what you are trying to achieve with your check and to what purpose?
If your database is not live, you won't be able to load umbraco to check the database
How to check database connection in U8
I realized simple healthcheck in my site. I need to know, is connection to database ok or not. For this I want to ping it. How to ping database from api controller code?
if your db connection is not correct umbraco will not work, you will get an error trying to access it, so if you are in umbraco then your dbis working.
It's not always true. When I stop Database and call /umbraco/api/keepalive/ping, it returns
But I have to know the state of the database connection. Is there some controller that gives information on the state of the database?
a ping will only tell you if the server is up or not, not whether something running on the server is running.
Did you try turning of the db and then trying to load umbraco? it won't load if the database is not active. So not sure what you are trying to achieve with your check and to what purpose?
If your database is not live, you won't be able to load umbraco to check the database
I did this solution
I think the best way to use IUmbracoDatabaseFactory
private readonly IUmbracoDatabaseFactory _umbracoDatabaseFactory;
is working on a reply...