VisualReCode / Cocoon

An implementation of the Strangler Fig pattern for ASP.NET Core
Apache License 2.0
62 stars 10 forks source link

Cocoon application getting a 400 Bad Request when making POST to web app #34

Closed conficient closed 1 year ago

conficient commented 1 year ago

We have a .NET 6 ASP.NET application using Cocoon, running on IIS 10 on Windows 2016 (on-premises), and it is talking to an ASP.NET WebForms application running on IIS8 on a different server. This has been working fine for a while.

Recently the application was misbehaving - a GET request to the WebForms application would work fine, but any WebForm postback to the app (using a POST) request resulted in a 400 Bad Request error.

I'm posting this as a guide for anyone who encounters a similar issue as we've now resolved it.

conficient commented 1 year ago

The cause of this error was a bug in the .NET 6 runtime version.

We were able to run the ASP.NET NET6 application on our dev machines and talk to the back-end website without issues, which pointed to the IIS10 web server having some difference that was causing the issue. I found this issue on the reverse-proxy repo which sounded exactly like our issue.

Our YARP version used for Cocoon had been upgraded in our branch of Cocoon to use YARP 2.0: this had exposed a bug in .NET 6 runtime prior to v6.0.12 which had this issue.

When we checked the IIS 10 server the .NET runtime used was v6.0.5 so this appeared to be the cause. Our development machines have later SDKs and runtimes installed, which is why it "worked on my machine".

Solution

We upgraded the .NET Runtime on the IIS 10 server to v6.0.16 using the hosting package.

Warning: doing this will make any .NET 6 web applications fail and you will need to restart IIS (using iisreset at the command line is quickest), so you may wish to do this out of business hours.