|
|
@ -1,8 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
using HttpClientStudy.Model;
|
|
|
|
using System.Threading ;
|
|
|
|
using HttpClientStudy.Service;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
using Microsoft.AspNetCore.Http.Features;
|
|
|
|
using Microsoft.AspNetCore.Http.Features;
|
|
|
@ -10,6 +10,10 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using HttpClientStudy.Model;
|
|
|
|
|
|
|
|
using HttpClientStudy.Service;
|
|
|
|
|
|
|
|
using HttpClientStudy.Config;
|
|
|
|
|
|
|
|
|
|
|
|
namespace HttpClientStudy.WebApp
|
|
|
|
namespace HttpClientStudy.WebApp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -33,7 +37,7 @@ namespace HttpClientStudy.WebApp
|
|
|
|
builder.Services.AddDistributedMemoryCache();
|
|
|
|
builder.Services.AddDistributedMemoryCache();
|
|
|
|
|
|
|
|
|
|
|
|
//配置Session
|
|
|
|
//配置Session
|
|
|
|
builder.Services.AddSession(option =>
|
|
|
|
builder.Services.AddSession(option =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
option.Cookie.Name = "HttpClientStudy";
|
|
|
|
option.Cookie.Name = "HttpClientStudy";
|
|
|
|
option.IOTimeout = TimeSpan.FromHours(1);
|
|
|
|
option.IOTimeout = TimeSpan.FromHours(1);
|
|
|
@ -41,7 +45,7 @@ namespace HttpClientStudy.WebApp
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//配置Kestrel服务器选项
|
|
|
|
//配置Kestrel服务器选项
|
|
|
|
builder.Services.Configure<KestrelServerOptions>( option =>
|
|
|
|
builder.Services.Configure<KestrelServerOptions>(option =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//ASP.NET Core 3.0 之前的版本,AllowSynchronousIO 默认是开启的
|
|
|
|
//ASP.NET Core 3.0 之前的版本,AllowSynchronousIO 默认是开启的
|
|
|
|
//设置 true :允许同步 IO 操作,这样允许接收Get请求中的请求体数据.但只能直接从流中读取,不能自动模型绑定。
|
|
|
|
//设置 true :允许同步 IO 操作,这样允许接收Get请求中的请求体数据.但只能直接从流中读取,不能自动模型绑定。
|
|
|
@ -49,7 +53,7 @@ namespace HttpClientStudy.WebApp
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//配置Form表单提交选项
|
|
|
|
//配置Form表单提交选项
|
|
|
|
builder.Services.Configure<FormOptions>(options =>
|
|
|
|
builder.Services.Configure<FormOptions>(options =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//options.BufferBody = true;
|
|
|
|
//options.BufferBody = true;
|
|
|
|
options.MultipartBodyLengthLimit = long.MaxValue;
|
|
|
|
options.MultipartBodyLengthLimit = long.MaxValue;
|
|
|
@ -116,11 +120,11 @@ namespace HttpClientStudy.WebApp
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//配置CORS跨域
|
|
|
|
//配置CORS跨域
|
|
|
|
builder.Services.AddCors(option =>
|
|
|
|
builder.Services.AddCors(option =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
option.AddPolicy("AllowAll", builder =>
|
|
|
|
option.AddPolicy("AllowAll", builder =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
builder.SetIsOriginAllowed(_ => true).AllowAnyMethod().AllowAnyHeader().AllowCredentials();
|
|
|
|
builder.SetIsOriginAllowed(_ => true).AllowAnyMethod().AllowAnyHeader().AllowCredentials();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -174,7 +178,7 @@ namespace HttpClientStudy.WebApp
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
|
|
#region 配置Http管道
|
|
|
|
#region 配置Http管道
|
|
|
|
|
|
|
|
|
|
|
|
//耗时统计中间件
|
|
|
|
//耗时统计中间件
|
|
|
|