I have a problem I am working on a site in asp.net core 2.0, locally everything works fine the connection of the BD does not give any problem, now the site I uploaded to Ubuntu 16.04 server, until then everything is fine, yesterday I went up the bd to make the connection and I find the surprise of this error:
ArgumentNullException: Value can not be null. Parameter name: connectionString
When I'm going to enter the login view, it sends me this error, I'm totally lost, I do not understand what's happening, if it's a configuration error or something is wrong with my code
This is my appsettings.json code
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"StringDeConexion": "server=localhost;userid=root;password=123;port=3306;database=bd",
"Context": "Server=(localdb)\mssqllocaldb;Database=Context-f56662ed-1bef-4423-8207-a721623d4659;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
On the other hand, the error is generated in Starup.cs
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// coneccion con MySQL
services.AddDbContext<Context>(options =>
options.UseMySql(Configuration.GetConnectionString("StringDeConexion")));
services.AddMemoryCache();
services.AddDistributedMemoryCache();
//inicio autenticacion
services.AddAuthentication(options =>
{
options.DefaultSignInScheme = new PathString("/Login/SignIn/");
options.DefaultSignOutScheme = new PathString("/Login/SignIn/");
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options => {
options.ExpireTimeSpan = TimeSpan.FromMinutes(15);//tiempo de la sesion
options.LoginPath = new PathString("/Login/SignIn/");//retorna vista si no hay permisos
});
// fin de autenticacion
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
// auntentificacion
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
Please if you could help me