MongoDB.Driver.MongoAuthenticationException,MongoDB.Driver.MongoAuthenticationException -
ommand 'authenticate' failed: auth failed (response: { "ok" : 0.0, "errmsg" : "auth failed", "code" : 18, "codeName" : "AuthenticationFailed" })
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: MongoDB.Driver.
Source Error:
|
Stack Trace:
Code_ --
protected void Page_Load(object sender, EventArgs e)
{
MongoUrl url = new MongoUrl(ConfigurationManager. ConnectionStrings["mycon"]. ConnectionString);
var client = new MongoClient(url);
//var db = client.GetDatabase(url. DatabaseName, null);
// now you can get collections from db
// var connectionString = "mongodb://admin:password@ localhost/admin";
MongoClient Client_ = new MongoClient(url);
MongoServer ms = Client_.GetServer();
ms.Ping();
MongoDatabase md = ms.GetDatabase("DatabaseName");
MongoCollection<BsonDocument> _documents = md.GetCollection<BsonDocument> ("CollectionName");
//var oc = new BsonDocument("sasa", "saa");
foreach (var item in _documents.FindAll())
{
Response.Write(item.ToString() );
}
}
No comments:
Post a Comment