我做了一个服务,托管在一个azure webapp上。这将用于上传文件。IIS具有内置的安全功能,可限制文件上载大小。
为了解决这个问题,我在web.config中添加了以下内容
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="80000000" />
</requestFiltering>
</security>
</system.webServer>
...
<system.web>
<httpRuntime maxRequestLength="80000" targetFramework="4.5.2" executionTimeout="9000" />
</system.web>然而,这对我来说并不起作用。只要我上传一个大文件(例如50MB),它就会给我一个404。当我上传一个较小的文件(10mb)时,它工作得很好。该服务是soap,并通过https调用。调用没有超时,异常发生在调用的5段内,我猜测它上传了30mb,然后它认为自己受到了攻击并中止。
我是不是漏掉了什么?
发布于 2016-04-08 12:37:59
您可以转到以下文件夹:
%windir%\system32\inetsrv\
运行命令:
appcmd set config -section:requestFiltering -requestLimits.maxAllowedContentLength:80000000或者,如果您只想为您的应用程序设置它,请运行以下命令:
appcmd set config "Default Web Site/" -section:requestFiltering -requestLimits.maxAllowedContentLength:80000000此外,您还需要在web.config中将overrideModeDefault更新为“Allow”:
<section name="requestFiltering" overrideModeDefault="Allow" />然后,您可以使用appcmd.exe更新您的web.config
希望this article和this article能帮助你。
关于如何使用appcmd.exe,您可以查看https://technet.microsoft.com/en-us/library/cc772200%28v=ws.10%29.aspx
之后,将你的项目部署到azure webapp,然后重试。
发布于 2019-03-21 00:29:50
我做了这样的配置,但我解决了我的问题,在我的ControllerBase上类似于:
protected override void OnResultExecuting(ResultExecutingContext filterContext)
{
base.OnResultExecuting(filterContext);
if(filterContext.Result.GetType().Name == "JsonResult")
filterContext.Result.GetType().GetProperty("MaxJsonLength").SetValue(filterContext.Result, int.MaxValue);
}发布于 2022-02-16 12:28:34
对于经典的ASP用户,除了web.config设置外,还要检查此设置:
IIS >网站上的CLick > ASP >限制属性>最大请求实体正文限制
https://stackoverflow.com/questions/36480897
复制相似问题