| | |
| | | using Microsoft.AspNetCore.Hosting; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Http.Connections; |
| | | using Microsoft.AspNetCore.Http.Features; |
| | | using Microsoft.AspNetCore.HttpsPolicy; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.AspNetCore.Mvc.Authorization; |
| | | using Microsoft.AspNetCore.Server.Kestrel.Core; |
| | | using Microsoft.AspNetCore.StaticFiles; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | |
| | | string basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); |
| | | string xmlPath = Path.Combine(basePath, "VueWebCoreApi.xml"); |
| | | c.IncludeXmlComments(xmlPath, true); |
| | | |
| | | }); |
| | | #endregion |
| | | |
| | |
| | | //设置Cookies |
| | | services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); |
| | | |
| | | #region 允许大文件上传 |
| | | //允许上传大文件 |
| | | services.Configure<IISServerOptions>(options => |
| | | { |
| | | options.MaxRequestBodySize = 1073741824;//此处限制最大1G |
| | | }); |
| | | //解决文件上传Multipart body length limit 134217728 exceeded. |
| | | services.Configure<FormOptions>(x => |
| | | { |
| | | x.ValueLengthLimit = int.MaxValue; |
| | | x.MultipartBodyLengthLimit = 1073741824; //此处限制最大1G |
| | | }); |
| | | #endregion 允许大文件上传 |
| | | } |
| | | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
| | | public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLeftTime, ILoggerFactory loggerFactory) |
| | |
| | | //添加静态文件中间件 |
| | | app.UseDefaultFiles(); |
| | | //添加授权文件 |
| | | app.UseStaticFiles(new StaticFileOptions() { |
| | | ContentTypeProvider = new FileExtensionContentTypeProvider() { |
| | | app.UseStaticFiles(new StaticFileOptions() |
| | | { |
| | | ContentTypeProvider = new FileExtensionContentTypeProvider() |
| | | { |
| | | Mappings = { |
| | | [".xls"] = "application/vnd.ms-excel", |
| | | [".apk"] = "application/vnd.android.package-archive" |