diff --git a/src/client/Bootstrap.Client/Bootstrap.Client.csproj b/src/client/Bootstrap.Client/Bootstrap.Client.csproj
index b5cd5be0..7cc814af 100644
--- a/src/client/Bootstrap.Client/Bootstrap.Client.csproj
+++ b/src/client/Bootstrap.Client/Bootstrap.Client.csproj
@@ -9,9 +9,8 @@
-
-
+
diff --git a/src/client/Bootstrap.Client/Program.cs b/src/client/Bootstrap.Client/Program.cs
index 9bd3da05..f5c6ea30 100644
--- a/src/client/Bootstrap.Client/Program.cs
+++ b/src/client/Bootstrap.Client/Program.cs
@@ -1,5 +1,5 @@
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
namespace Bootstrap.Client
{
@@ -14,16 +14,15 @@ namespace Bootstrap.Client
///
public static void Main(string[] args)
{
- CreateWebHostBuilder(args).Build().Run();
+ CreateHostBuilder(args).Build().Run();
}
-
///
///
///
///
///
- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseStartup();
+ public static IHostBuilder CreateHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(builder => builder.UseStartup());
}
}
diff --git a/src/client/Bootstrap.Client/Startup.cs b/src/client/Bootstrap.Client/Startup.cs
index d7671a4a..c81ae680 100644
--- a/src/client/Bootstrap.Client/Startup.cs
+++ b/src/client/Bootstrap.Client/Startup.cs
@@ -1,6 +1,7 @@
using Bootstrap.Client.DataAccess;
using Longbow.Web;
using Longbow.Web.SignalR;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@@ -8,6 +9,7 @@ using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
@@ -54,19 +56,19 @@ namespace Bootstrap.Client
services.AddBootstrapHttpClient();
services.AddIPLocator(DictHelper.ConfigIPLocator);
services.AddOnlineUsers();
- services.AddSignalR().AddJsonProtocalDefault();
services.AddResponseCompression();
services.AddBootstrapAdminAuthentication();
- services.AddMvc(options =>
+ services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireBootstrapAdminAuthorizate().Build());
+ services.AddControllersWithViews(options =>
{
- options.Filters.Add();
options.Filters.Add();
- }).AddJsonOptions(options =>
+ options.Filters.Add>();
+ }).AddNewtonsoftJson(op =>
{
- options.SerializerSettings.ContractResolver = new DefaultContractResolver();
- options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
- JsonConvert.DefaultSettings = () => options.SerializerSettings;
- }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
+ op.SerializerSettings.ContractResolver = new DefaultContractResolver();
+ op.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
+ JsonConvert.DefaultSettings = () => op.SerializerSettings;
+ });
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -75,7 +77,7 @@ namespace Bootstrap.Client
///
///
///
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All });
if (env.IsDevelopment())
@@ -94,15 +96,16 @@ namespace Bootstrap.Client
app.UseResponseCompression();
app.UseStaticFiles();
app.UseCookiePolicy();
- app.UseBootstrapAdminAuthentication(RoleHelper.RetrievesByUserName, RoleHelper.RetrievesByUrl, AppHelper.RetrievesByUserName);
+
+ app.UseRouting();
+ app.UseAuthentication();
+ app.UseAuthorization();
+ app.UseBootstrapAdminAuthorization(RoleHelper.RetrievesByUserName, RoleHelper.RetrievesByUrl, AppHelper.RetrievesByUserName);
app.UseCacheManager();
app.UseOnlineUsers(callback: TraceHelper.Save);
- app.UseSignalR(routes => { routes.MapHub("/NotiHub"); });
- app.UseMvc(routes =>
+ app.UseEndpoints(endpoints =>
{
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
+ endpoints.MapDefaultControllerRoute().RequireAuthorization();
});
}
}