feat: Client 支持 NETCore 3.0
This commit is contained in:
parent
42a1c16bbb
commit
a86e717ced
|
@ -9,9 +9,8 @@
|
||||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.0" />
|
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.0" />
|
||||||
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
||||||
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
|
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Microsoft.AspNetCore;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Bootstrap.Client
|
namespace Bootstrap.Client
|
||||||
{
|
{
|
||||||
|
@ -14,16 +14,15 @@ namespace Bootstrap.Client
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
CreateHostBuilder(args).Build().Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
WebHost.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.UseStartup<Startup>();
|
.ConfigureWebHostDefaults(builder => builder.UseStartup<Startup>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Bootstrap.Client.DataAccess;
|
using Bootstrap.Client.DataAccess;
|
||||||
using Longbow.Web;
|
using Longbow.Web;
|
||||||
using Longbow.Web.SignalR;
|
using Longbow.Web.SignalR;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
@ -8,6 +9,7 @@ using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using System;
|
using System;
|
||||||
|
@ -54,19 +56,19 @@ namespace Bootstrap.Client
|
||||||
services.AddBootstrapHttpClient();
|
services.AddBootstrapHttpClient();
|
||||||
services.AddIPLocator(DictHelper.ConfigIPLocator);
|
services.AddIPLocator(DictHelper.ConfigIPLocator);
|
||||||
services.AddOnlineUsers();
|
services.AddOnlineUsers();
|
||||||
services.AddSignalR().AddJsonProtocalDefault();
|
|
||||||
services.AddResponseCompression();
|
services.AddResponseCompression();
|
||||||
services.AddBootstrapAdminAuthentication();
|
services.AddBootstrapAdminAuthentication();
|
||||||
services.AddMvc(options =>
|
services.AddAuthorization(options => options.DefaultPolicy = new AuthorizationPolicyBuilder().RequireBootstrapAdminAuthorizate().Build());
|
||||||
|
services.AddControllersWithViews(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add<BootstrapAdminAuthorizeFilter>();
|
|
||||||
options.Filters.Add<ExceptionFilter>();
|
options.Filters.Add<ExceptionFilter>();
|
||||||
}).AddJsonOptions(options =>
|
options.Filters.Add<SignalRExceptionFilter<SignalRHub>>();
|
||||||
|
}).AddNewtonsoftJson(op =>
|
||||||
{
|
{
|
||||||
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
op.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
op.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||||
JsonConvert.DefaultSettings = () => options.SerializerSettings;
|
JsonConvert.DefaultSettings = () => op.SerializerSettings;
|
||||||
}).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -75,7 +77,7 @@ namespace Bootstrap.Client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="app"></param>
|
/// <param name="app"></param>
|
||||||
/// <param name="env"></param>
|
/// <param name="env"></param>
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All });
|
app.UseForwardedHeaders(new ForwardedHeadersOptions() { ForwardedHeaders = ForwardedHeaders.All });
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
|
@ -94,15 +96,16 @@ namespace Bootstrap.Client
|
||||||
app.UseResponseCompression();
|
app.UseResponseCompression();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseCookiePolicy();
|
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.UseCacheManager();
|
||||||
app.UseOnlineUsers(callback: TraceHelper.Save);
|
app.UseOnlineUsers(callback: TraceHelper.Save);
|
||||||
app.UseSignalR(routes => { routes.MapHub<SignalRHub>("/NotiHub"); });
|
app.UseEndpoints(endpoints =>
|
||||||
app.UseMvc(routes =>
|
|
||||||
{
|
{
|
||||||
routes.MapRoute(
|
endpoints.MapDefaultControllerRoute().RequireAuthorization();
|
||||||
name: "default",
|
|
||||||
template: "{controller=Home}/{action=Index}/{id?}");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue