diff --git a/src/Yavsc/Controllers/Communicating/BlogspotController.cs b/src/Yavsc/Controllers/Communicating/BlogspotController.cs index 8853181d..87eaa5a4 100644 --- a/src/Yavsc/Controllers/Communicating/BlogspotController.cs +++ b/src/Yavsc/Controllers/Communicating/BlogspotController.cs @@ -48,7 +48,7 @@ namespace Yavsc.Controllers return View(); } - [Route("/Title/{id?}")] + [Route("~/Title/{id?}")] [AllowAnonymous] public IActionResult Title(string id) { @@ -61,7 +61,7 @@ namespace Yavsc.Controllers ).ToList()); } - [Route("/Blog/{userName}/{pageLen?}/{pageNum?}")] + [Route("~/Blog/{userName}/{pageLen?}/{pageNum?}")] [AllowAnonymous] public async Task UserPosts(string userName, int pageLen=10, int pageNum=0) { diff --git a/src/Yavsc/HostingExtensions.cs b/src/Yavsc/HostingExtensions.cs index ac382851..b54bef2b 100644 --- a/src/Yavsc/HostingExtensions.cs +++ b/src/Yavsc/HostingExtensions.cs @@ -149,17 +149,18 @@ internal static class HostingExtensions Config.GServiceAccount = JsonConvert.DeserializeObject(safile.OpenText().ReadToEnd()); } +var services = builder.Services; - builder.Services.AddRazorPages(); + services.AddRazorPages(); - builder.Services.AddDbContext(options => + services.AddDbContext(options => options.UseNpgsql(builder.Configuration.GetConnectionString("Default"))); - builder.Services.AddIdentity() + services.AddIdentity() .AddEntityFrameworkStores() .AddDefaultTokenProviders(); - builder.Services + services .AddIdentityServer(options => { options.Events.RaiseErrorEvents = true; @@ -175,7 +176,7 @@ internal static class HostingExtensions .AddInMemoryClients(Config.Clients) .AddAspNetIdentity().AddServerSideSessions(); - builder.Services.AddAuthentication() + services.AddAuthentication() .AddGoogle(options => { options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; @@ -186,7 +187,7 @@ internal static class HostingExtensions options.ClientId = "325408689282-6bekh7p3guj4k0f3301a6frf025cnrk1.apps.googleusercontent.com"; options.ClientSecret = "XV1DLrq8cQE2JI4gZP3h6d8y"; }); -builder.Services.Configure(options => + services.Configure(options => { CultureInfo[] supportedCultures = new[] { @@ -217,11 +218,11 @@ builder.Services.Configure(options => }; }); - builder.Services.AddSignalR(); + services.AddSignalR(); - builder.Services.AddOptions(); + services.AddOptions(); - _ = builder.Services.AddCors(options => + _ = services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => { @@ -231,13 +232,13 @@ builder.Services.Configure(options => // Add the system clock service - _ = builder.Services.AddSingleton(); + _ = services.AddSingleton(); - _ = builder.Services.AddSingleton(); - _ = builder.Services.AddSingleton(); - _ = builder.Services.AddTransient(); + _ = services.AddSingleton(); + _ = services.AddSingleton(); + _ = services.AddTransient(); -builder.Services.AddMvc(config => + services.AddMvc(config => { /* var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() @@ -260,9 +261,8 @@ builder.Services.AddMvc(config => options.ResourcesPath = "Resources"; }).AddDataAnnotationsLocalization(); -var services = builder.Services; - _ = services.AddTransient(); + _ = services.AddTransient(); _ = services.AddTransient(); _ = services.AddTransient(); _ = services.AddTransient(); @@ -299,7 +299,6 @@ var services = builder.Services; _ = services.AddControllersWithViews() .AddNewtonsoftJson(); LoadGoogleConfig(configuration); - return builder.Build(); } @@ -314,6 +313,9 @@ var services = builder.Services; app.UseRouting(); app.UseIdentityServer(); app.UseAuthorization(); + app.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); app.MapRazorPages() .RequireAuthorization(); ConfigureWorkflow(); @@ -329,6 +331,7 @@ var services = builder.Services; payPalSettings, googleAuthSettings, localization, loggerFactory, app.Environment.EnvironmentName ); app.ConfigureFileServerApp(); + return app; }