gpt4 book ai didi

servicestack - 请求正文太大

转载 作者:行者123 更新时间:2023-12-03 16:20:46 26 4
gpt4 key购买 nike

当我尝试将 80mb 文件从 postman 上传到我在 IISExpress 上的 Visual Studio 2019 中运行的本地端点时,我收到以下错误:

The request filtering module is configured to deny a request that exceeds the request content length.


所以我将它添加到了项目的 applicationhost.config 中:
<system.web>
<httpRuntime maxRequestLength="1050000" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824"/>
</requestFiltering>
</security>
当我发出 API 请求时,这会阻止错误的发生,但现在我只是得到一个 ServiceStack 生成的“快照”页面,告诉我请求花费了多长时间和日期,但我的实际端点从未被命中。
在我的日志中,我可以看到 ServiceStack 抛出此异常:

2020-07-20 01:57:56.0497||ERROR|ServiceStackHost|Request body toolarge. Microsoft.AspNetCore.Server.IIS.BadHttpRequestException:Request body too large. atMicrosoft.AspNetCore.Server.IIS.BadHttpRequestException.Throw(RequestRejectionReasonreason) atMicrosoft.AspNetCore.Server.IIS.Core.IISHttpContext.InitializeRequestIO()atMicrosoft.AspNetCore.Server.IIS.Core.IISHttpContext.ReadAsync(Memory1 memory, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.IIS.Core.HttpRequestStream.ReadAsyncInternal(Memory1buffer, CancellationToken cancellationToken) atMicrosoft.AspNetCore.WebUtilities.BufferedReadStream.EnsureBufferedAsync(Int32minCount, CancellationToken cancellationToken) atMicrosoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Byte[]buffer, Int32 offset, Int32 count, CancellationTokencancellationToken) atMicrosoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Streamstream, ArrayPool1 bytePool, Nullable1 limit, CancellationTokencancellationToken) atMicrosoft.AspNetCore.WebUtilities.MultipartReader.ReadNextSectionAsync(CancellationTokencancellationToken) atMicrosoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationTokencancellationToken) atMicrosoft.AspNetCore.Http.Features.FormFeature.ReadForm() atMicrosoft.AspNetCore.Http.DefaultHttpRequest.get_Form() atServiceStack.Host.NetCore.NetCoreRequest.get_FormData() inC:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\NetCore\NetCoreRequest.cs:line167 atServiceStack.HttpRequestExtensions.GetFlattenedRequestParams(IRequestrequest) inC:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\HttpRequestExtensions.cs:line555 at ServiceStack.Host.RestHandler.CreateRequestAsync(IRequesthttpReq, IRestPath restPath) inC:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\RestHandler.cs:line132 at ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequestreq, IResponse httpRes, String operationName) inC:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\RestHandler.cs:line89|url: |action:


所以 body 长度仍然需要在某处设置,但我看的每个地方都指向我已经使用过的配置。
是否需要额外设置或者这是一个 ServiceStack 问题?

最佳答案

我在启动时缺少这个选项:


services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = int.MaxValue;
});

services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB
});

关于servicestack - 请求正文太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62987343/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com