私は c# と asp.net mvc (visual studio 2015) を使用しています。mongodb を C# に接続しようとすると、次のエラーが表示されます。
MongoDB.Driver.MongoConfigurationException: The connection string 'mongodb:://localhost' is not valid.
エラーソースは次のとおりです。
var client = new MongoClient(Settings.Default.bigdataconexionstrin);
これは私のコードです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using WebApplication5.Properties;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
namespace WebApplication5.Controllers
{
[Authorize]
public class HomeController : Controller
{
public IMongoDatabase db1;
public HomeController()
{
var client = new MongoClient(Settings.Default.bigdataconexionstrin);
MongoClientSettings settings = new MongoClientSettings();
settings.Server = new MongoServerAddress("localhost", 27017);
this.db1 = client.GetDatabase(Settings.Default.db);
}
public ActionResult Index()
{
return View();
}
}
}