更改格式为utf-8
This commit is contained in:
parent
f7c6256e1b
commit
0167fc3d26
@ -17,34 +17,34 @@ builder.Services.AddControllers();
|
|||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
//注入HttpContextAccessor
|
//注入HttpContextAccessor
|
||||||
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
||||||
|
|
||||||
//配置跨域
|
//配置跨域
|
||||||
builder.Services.AddCors(c =>
|
builder.Services.AddCors(c =>
|
||||||
{
|
{
|
||||||
c.AddPolicy("Policy", policy =>
|
c.AddPolicy("Policy", policy =>
|
||||||
{
|
{
|
||||||
policy.WithOrigins(builder.Configuration["corsUrls"].Split(',', StringSplitOptions.RemoveEmptyEntries))
|
policy.WithOrigins(builder.Configuration["corsUrls"].Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||||
.AllowAnyHeader()//允许任意头
|
.AllowAnyHeader()//允许任意头
|
||||||
.AllowCredentials()//允许cookie
|
.AllowCredentials()//允许cookie
|
||||||
.AllowAnyMethod();//允许任意方法
|
.AllowAnyMethod();//允许任意方法
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//注入SignalR实时通讯,默认用json传输
|
//注入SignalR实时通讯,默认用json传输
|
||||||
builder.Services.AddSignalR();
|
builder.Services.AddSignalR();
|
||||||
//消除Error unprotecting the session cookie警告
|
//消除Error unprotecting the session cookie警告
|
||||||
builder.Services.AddDataProtection()
|
builder.Services.AddDataProtection()
|
||||||
.PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection"));
|
.PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection"));
|
||||||
//普通验证码
|
//普通验证码
|
||||||
builder.Services.AddHeiCaptcha();
|
builder.Services.AddHeiCaptcha();
|
||||||
//builder.Services.AddSession();
|
//builder.Services.AddSession();
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
//绑定整个对象到Model上
|
//绑定整个对象到Model上
|
||||||
builder.Services.Configure<OptionsSetting>(builder.Configuration);
|
builder.Services.Configure<OptionsSetting>(builder.Configuration);
|
||||||
|
|
||||||
//jwt 认证
|
//jwt 认证
|
||||||
builder.Services.AddAuthentication(options =>
|
builder.Services.AddAuthentication(options =>
|
||||||
{
|
{
|
||||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
@ -58,19 +58,19 @@ builder.Services.AddAuthentication(options =>
|
|||||||
InternalApp.InternalServices = builder.Services;
|
InternalApp.InternalServices = builder.Services;
|
||||||
builder.Services.AddAppService();
|
builder.Services.AddAppService();
|
||||||
builder.Services.AddSingleton(new AppSettings(builder.Configuration));
|
builder.Services.AddSingleton(new AppSettings(builder.Configuration));
|
||||||
//开启计划任务
|
//开启计划任务
|
||||||
builder.Services.AddTaskSchedulers();
|
builder.Services.AddTaskSchedulers();
|
||||||
//初始化db
|
//初始化db
|
||||||
DbExtension.AddDb(builder.Configuration);
|
DbExtension.AddDb(builder.Configuration);
|
||||||
|
|
||||||
//注册REDIS 服务
|
//注册REDIS 服务
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
//RedisServer.Initalize();
|
//RedisServer.Initalize();
|
||||||
});
|
});
|
||||||
builder.Services.AddMvc(options =>
|
builder.Services.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(GlobalActionMonitor));//全局注册
|
options.Filters.Add(typeof(GlobalActionMonitor));//全局注册
|
||||||
})
|
})
|
||||||
.AddJsonOptions(options =>
|
.AddJsonOptions(options =>
|
||||||
{
|
{
|
||||||
@ -84,7 +84,7 @@ var app = builder.Build();
|
|||||||
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
|
|
||||||
//使可以多次多去body内容
|
//使可以多次多去body内容
|
||||||
app.Use((context, next) =>
|
app.Use((context, next) =>
|
||||||
{
|
{
|
||||||
context.Request.EnableBuffering();
|
context.Request.EnableBuffering();
|
||||||
@ -94,26 +94,26 @@ app.Use((context, next) =>
|
|||||||
}
|
}
|
||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
//开启访问静态文件/wwwroot目录文件,要放在UseRouting前面
|
//开启访问静态文件/wwwroot目录文件,要放在UseRouting前面
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
//开启路由访问
|
//开启路由访问
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseCors("Policy");//要放在app.UseEndpoints前。
|
app.UseCors("Policy");//要放在app.UseEndpoints前。
|
||||||
//app.UseHttpsRedirection();
|
//app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
//开启缓存
|
//开启缓存
|
||||||
app.UseResponseCaching();
|
app.UseResponseCaching();
|
||||||
//恢复/启动任务
|
//恢复/启动任务
|
||||||
app.UseAddTaskSchedulers();
|
app.UseAddTaskSchedulers();
|
||||||
//使用全局异常中间件
|
//使用全局异常中间件
|
||||||
app.UseMiddleware<GlobalExceptionMiddleware>();
|
app.UseMiddleware<GlobalExceptionMiddleware>();
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
//设置socket连接
|
//设置socket连接
|
||||||
endpoints.MapHub<MessageHub>("/msgHub");
|
endpoints.MapHub<MessageHub>("/msgHub");
|
||||||
|
|
||||||
endpoints.MapControllerRoute(
|
endpoints.MapControllerRoute(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user