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