Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamianEdwards <damian@damianedwards.com>2021-07-07 02:09:37 +0300
committerDamian Edwards <damian@damianedwards.com>2021-07-07 04:10:30 +0300
commit7699bab0fc5b1451272c7873af45990932d3d148 (patch)
treef4a0f5482d7d5947a67af650517293dab7f86ed3 /src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp
parentdde6daa939c5dee499726017ceb322b714e8fc17 (diff)
Address feedback
- put connection string in its own variable - add explicit call to UseRouting() to avoid issue with middleware that re-runs the pipeline with a different path (e.g. UseExceptionHandler)
Diffstat (limited to 'src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp')
-rw-r--r--src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs
index 2bc91a83fc..7560314201 100644
--- a/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs
+++ b/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Program.cs
@@ -46,13 +46,12 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
#if (IndividualLocalAuth)
+var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDbContext>(options =>
#if (UseLocalDB)
- options.UseSqlServer(
- builder.Configuration.GetConnectionString("DefaultConnection")));
+ options.UseSqlServer(connectionString));
#else
- options.UseSqlite(
- builder.Configuration.GetConnectionString("DefaultConnection")));
+ options.UseSqlite(connectionString));
#endif
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
@@ -140,6 +139,8 @@ app.UseHttpsRedirection();
app.UseStaticFiles();
+app.UseRouting();
+
#if (OrganizationalAuth || IndividualAuth)
app.UseAuthentication();
app.UseAuthorization();