0

How can I check MongoDB connecting string is valid or not using asp.net core.

var connectionString="mongodb://127.0.0.1:27017/local";
MongoClient client = new MongoClient(connectionString);
var server = client.GetServer();
server.Ping();
server.Disconnect();

This code is not working

Ramil Aliyev 007
  • 4,437
  • 2
  • 31
  • 47
manish
  • 11
  • 1
  • 3
  • What do you mean by *not working*? Does it throw an exception or show incorrect results? And could you please specify what nuget package you are using – Alexander May 04 '21 at 12:15
  • Does this answer your question? [MongoServer.State equivalent in the 2.0 driver](https://stackoverflow.com/questions/29459990/mongoserver-state-equivalent-in-the-2-0-driver) – Alexander May 04 '21 at 12:22
  • thanks for the response I need to know how to valid MongoDB connection string in the asp.net core – manish May 05 '21 at 04:48

0 Answers0