我想将照片上传到ASP.NETWeb API,但上传的一些照片返回错误。我成功上传到文件大小17002或更小,但我没有上传文件大小17345或更大。注意:Web API上的EnableCors和maxRequest estL长度="307200"和maxAlloweContentL长度="314572800"全部正常。错误(例如,当我尝试上传到17345大小的照片文件时):
XMLHttpRequest无法加载http://localhost:42658/API/MyApi/UploadFile。请求的资源上没有“Access-Control-Allow-Origin”标头。因此,不允许访问源“http://localhost:4200”。响应的HTTP状态代码为500。
我正在使用IIS7。有人能解决这个问题吗?
我有一个同样的问题,我发现有两个标签
`<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
<httpRuntime targetFramework="4.6.1"/>`
问题解决了,我把它们合二为一,就像这样:
<httpRuntime targetFramework="4.6.1" maxRequestLength="1048576" executionTimeout="3600" />
你试过像下面一样吗?
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>