I use c# and asp.net mvc (visual studio 2015). When I try to connect mongodb to c#,this error appears:
MongoDB.Driver.MongoConfigurationException: The connection string 'mongodb:://localhost' is not valid.
and the error source is:
var client = new MongoClient(Settings.Default.bigdataconexionstrin);
this is my code :
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();
}
}
}