gpt4 book ai didi

c# - 响应 : 413 Request Entity Too Large

转载 作者:行者123 更新时间:2023-12-03 16:29:31 25 4
gpt4 key购买 nike

当发布一个可以包含一个或多个文件(作为 base64 字符串)的请求时,我收到以下错误响应:

ERROR 2018-11-22 09:54:18,244 [13 ] Mvc.ExceptionHandling.AbpExceptionFilter - The remote server returned an unexpected response: (413) Request Entity Too Large. System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (413) Request Entity Too Large. at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult) --- End of stack trace from previous location where exception was thrown --- at ...



我已经搜索了如何解决这个问题,但我一直被重定向到 WCF 解决方案。

我已将以下内容添加到我的 WebApi 项目的 web.config 中,但它似乎没有什么区别。
<configuration>
<system.webServer>
....
<asp>
<limits maxRequestEntityAllowed="2147483648"/>
</asp>
<serverRuntime uploadReadAheadSize="2147483647" />
</system.webServer>
</configuration>

任何人都可以帮助我或为我指出正确的资源吗?

最佳答案

您需要更改两个限制。红隼和 IIS。

您可以在 Program.cs 中更改 Kestrel 的 MaxRequestBodySize 限制。

public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = long.MaxValue;
})
.UseIISIntegration()
.Build();
}

并且可以在 web.config 中更改 IIS 的限制:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
</configuration>

关于c# - 响应 : 413 Request Entity Too Large,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53428474/

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