chore: replace legacy routing code with proper 3.1
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2020-12-28 14:36:36 +01:00
parent f0535f7797
commit 4b6e560e6d
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -35,11 +35,9 @@ namespace pwt_0x01_ng
options.HttpOnly = HttpOnlyPolicy.Always;
options.Secure = CookieSecurePolicy.Always;
});
services.Configure<MvcOptions>(options => {
/* necessary due to a switch to 3.1 */
options.EnableEndpointRouting = false;
});
services.AddControllersWithViews();
services.AddRazorPages();
var connectionString = Environment.GetEnvironmentVariable("DB_CONNECTION_STRING");
services.AddDbContext<DBContext>(options =>
@ -64,19 +62,23 @@ namespace pwt_0x01_ng
app.UseExceptionHandler("/Home/Error");
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllerRoute(
name: "areas",
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
);
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"
);
});
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "areas",
template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
);
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}