一,全局限制
Startup.cs 中 ConfigureServices 方法中添加
services.Configure<FormOptions>(options => { options.MultipartBodyLengthLimit = 50000; });
二,单页面限制
services.AddRazorPages(options => { options.Conventions.AddPageApplicationModelConvention("/FileUploadPage", model => { model.Filters.Add(new RequestSizeLimitAttribute(5000)); }); }).AddRazorRuntimeCompilation()
三,cshtml界面限制
@attribute [RequestSizeLimitAttribute(50000)]