简体   繁体   English

IIS Express 和 Visual Studio 2019 - 413.1 - 请求实体太大

[英]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.公告讨论了在MVCMiddleware以及我上面展示的全局中执行此操作的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 http 错误 413.1 - 请求实体在 .net Core 中太大 - http error 413.1 - request entity too large in .net Core Visual Studio 2019“无法连接到 web 服务器‘IIS Express’” - Visual studio 2019 “Unable to connect to web server 'IIS Express'” 无法在 Visual Studio 2019 中运行 IIS Express - Can't run IIS Express in visual studio 2019 从 Visual Studio 2019 运行时在 IIS Express 上获取 NullReferenceException - Getting NullReferenceException on IIS Express while running from Visual Studio 2019 Visual Studio 2019 - IIS Express - 连接已重置 (ERR_CONNECTION_RESET) - Visual Studio 2019 - IIS Express - The connection was reset (ERR_CONNECTION_RESET) Visual Studio 2019 中的 AWS 无服务器模板删除了 IIS 快速调试选项 - AWS Serverless Template in Visual Studio 2019 Removes the IIS Express Debug Option 将 IIS 与 Visual Studio 2019 和 ASP.NET CORE 3.1 一起使用 - Using IIS with Visual Studio 2019 and ASP.NET CORE 3.1 413 请求实体太大 - Web API - 413 request entity too large - Web API 响应:413 请求实体太大 - response: 413 Request Entity Too Large 无法在 Visual Studio 2019 中连接到 SQL Server Express - Unable to connect to SQL Server Express in visual studio 2019
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM