Adatepd appsettings-Files

This commit is contained in:
Giuseppe D’Ettorre
2026-07-09 17:18:21 +02:00
parent 0e5d5c2a17
commit f2a1efc807
4 changed files with 17 additions and 10 deletions
+2 -1
View File
@@ -3,6 +3,7 @@ using RazorPagesMovie.Data;
using RazorPagesMovie.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddJsonFile("appsettings.Local.json", optional: true, reloadOnChange: true);
builder.Services.AddDbContext<RazorPagesMovieContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("RazorPagesMovieContext") ?? throw new InvalidOperationException("Connection string 'RazorPagesMovieContext' not found.")));
builder.Services.AddRazorPages();
@@ -28,4 +29,4 @@ app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
app.Run();
+5 -2
View File
@@ -1,9 +1,12 @@
{
"DetailedErrors": true,
"ConnectionStrings": {
"RazorPagesMovieContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesMovieContext-bc;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Default": "Debug",
"Microsoft.AspNetCore": "Information"
}
}
}
+8 -2
View File
@@ -1,5 +1,11 @@
{
{
"ConnectionStrings": {
"RazorPagesMovieContext": "Server=sqlserver,1433;Database=RazorPagesMovieContext;User Id=sa;Password=YourPassword123!;TrustServerCertificate=True"
},
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore": "Warning"
}
}
}
}
+2 -5
View File
@@ -5,8 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"RazorPagesMovieContext": "Server=(localdb)\\mssqllocaldb;Database=RazorPagesMovieContext-bc;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
"AllowedHosts": "*"
}