[英]IIS Express and Visual Studio 2019 - 413.1 - Request Entity Too Large
I have a.Net Core 2.2 Service to which I am trying to submit a large-ish request payload (including several base-64 encoded files).我有一个 .Net Core 2.2 服务,我正试图向其提交一个大型请求负载(包括几个 base-64 编码文件)。 Total size is just under 30mb.
总大小不到 30mb。 The controller immediately rejects with error 413.1 - Request Entity Too Large.
controller 立即拒绝并显示错误 413.1 - 请求实体太大。 I have done a bit of research on the issue, but most solutions focus on modifying
uploadReadAheadSize
in the full version of IIS (but this is IIS express, running locally in VS), or modifying the web.config file (this.Net Core project does not have one).我对这个问题做了一些研究,但大多数解决方案都集中在
uploadReadAheadSize
的完整版本中修改uploadReadAheadSize(但这是IIS express,在VS本地运行),或者修改web.config文件(this .Net Core项目没有)。 The project is not going to be deployed in IIS, so I don't think the solutions I've found would work for me at that point either.该项目不会在 IIS 中部署,所以我认为我找到的解决方案在那个时候也不适合我。 How can I make this work locally for debugging purposes?
我怎样才能使它在本地工作以进行调试?
The default request body size limit is 28.6 MB for .NET Core
>2.0对于
.NET Core
>2.0,默认请求正文大小限制为 28.6 MB
If you are not going to use IIS for your deployment and wanted to make it work for debugging purposes, you can use Kestrel and reset the maximum request body size restriction inside of your Program.cs
as shown below如果您不打算将 IIS 用于您的部署并想让它用于调试目的,您可以使用 Kestrel 并在
Program.cs
中重置最大请求正文大小限制,如下所示
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options => { options.Limits.MaxRequestBodySize = null; });
You can know more about Kestrel's configuration options from here你可以从这里了解更多关于 Kestrel 的配置选项
Further, this change has been introduced as a breaking change in the version 2.0 of .NET Core.此外,此更改已作为 .NET Core 2.0 版中的重大更改引入。 This announcement talks about the ways to perform this in
MVC
, Middleware
and also globally like I showed above.该公告讨论了在
MVC
、 Middleware
以及我上面展示的全局中执行此操作的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.