mongoDB不同版本的C#Drivers更换问题
页面错误信息
Command 'authenticate' failed: auth fails (response: { "errmsg" : "auth fails", "ok" : 0.0 }) 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.MongoCommandException: Command 'authenticate' failed: auth fails (response: { "errmsg" : "auth fails", "ok" : 0.0 })
MongoDB.Driver.dll 版本号1.7.0.4714
更换为
MongoDB.Driver.dll 版本号1.8.1.20
问题出现在连接串里
var connectionString = "mongodb://test:123456@localhost/"; var client = new MongoClient(connectionString);
修改为
var connectionString = "mongodb://test:123456@localhost/test"; var client = new MongoClient(connectionString);
就是在原来连接串后面加上库名,问题解决。
参考:http://cn.docs.mongodb.org/ecosystem/tutorial/authenticate-with-csharp-driver/