I'm getting below error in 10 % of my requests on production env.
I've tried also from local and many different browsers and devices (BrowserStack) and I still didn't succeed to reproduce an issue.
"errors": [
{
"status": "405",
"title": "Method Not Allowed",
"detail": "HTTP method is not allowed"
}
]
Error that is caught from browser console (Angular)
"error": "[ProgressEvent]",
"headers": "[ti]",
"message": "Http failure response for https://api.xxxxxx:5000/api/public-web/files: 0 Unknown Error",
"name": "HttpErrorResponse",
"ok": false,
"status": 0,
"statusText": "Unknown Error",
"url": "https://api.xxxxxx:5000/api/public-web/files"
POST https://api.xxxxxxx:5000/api/public-web/files/upload
Logs are from Sentry
Stack:
- .Net Core 6
- Angular 15 - Universal
- Server: Windows 2019 → IIS 10
1 ) I've covered CORS just on the IIS with above custom headers in web.config, not on the application side. - DONE
2) I’ve already tried to remove WEBDAV module - DONE
3) Also from IIS side I’ve turned on failed request tracing and logs, and on both sides of logs that request doesn’t even appears. - DONE
Firstly, I was thinking an issue is related to the CORS but although that I had already configured CORS on backend side, I've also added following to all response headers on the server in web-config (IIS)
as can be seen down bellow from full web.config
file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<modules>
<remove name="WebDAVModule"/>
</modules>
<httpProtocol>
<customHeaders>
<clear/>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Methods" value="GET,POST,PATCH,PUT,DELETE,OPTIONS"/>
<add name="Access-Control-Allow-Headers" value="*"/>
</customHeaders>
</httpProtocol>
<handlers>
<remove name="WebDAV"/>
<add name="aspNetCore" path="*" verb="GET,POST,PATCH,PUT,DELETE" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="None"/>
</handlers>
<aspNetCore processPath="dotnet" arguments=".\xxxx.Api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"/>
</system.webServer>
</location>
<system.webServer>
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose"/>
<add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose"/>
<add provider="ISAPI Extension" verbosity="Verbose"/>
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,ANCM,Rewrite,Cors,iisnode" verbosity="Verbose"/>
</traceAreas>
<failureDefinitions statusCodes="400-999"/>
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>
Route on the .Net Core:
[HttpPost("upload")]
[DisableRequestSizeLimit]
public async Task<IActionResult> Upload(IFormFile file, CancellationToken cancellationToken) {
var fileDto = await _fileService.UploadApplicationDocument(file, cancellationToken);
return ResponseObjectStatusCode(new ResponseObject<object>(fileDto));
}
It seems like HTTP Request doesn't reach the server at all…