Request Entity Too Large for Self Hosted ASP.Net Web API在Selfhost的api后台怎么解决Request Entity Too Large问题
如果用的IIS承载api,可以在web.config中添加配置来解决
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
<httpRuntime
maxRequestLength=""
executionTimeout="" />
</system.web>
但在Selfhost中App.config没办法添加此配置
正常的添加方法应该在添加selfhost绑定配置项时添加
var config = new HttpSelfHostConfiguration(host);
config.MaxReceivedMessageSize = ; // use config for this value
/*
other setup for the config
*/
using (var server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
Console.WriteLine("Insight.Web");
Console.ReadLine();
}