The issue 307 Temporary Redirect was thrown by from the Kestrel server for me when I was trying to deploy the ASP.NET core application in Linux operating system. Due to this web application was not working.
When I was trying to deploy my ASP.NET Core web application I ran the command dotnet webUi.dll where WebUi.dll is my application file. I could see my application started running and it was listening on ports 5000 and 5001. The port 5000 was for HTTP calls and 5001 for HTTPS calls.
Just to confirm whether I can browse the application which is running with the Kestrel server I tried to open the application with the CURL command as shown below, and I got a message saying HTTP/1.1 307 Temporary Redirect and that was from the Kestrel server.
If we observe the message, we could make out that HTTP calls are being redirected to https://localhost:5001. So all the HTTP calls are redirecting to HTTPS URL, due to this my web application was not working as expected as I was not ready for HTTPS deployment yet. I just wanted to test my application with HTTP first then I could set it up with HTTPS.
To prevent the automatic redirect from HTTP to HTTPS we have to go back to our source code and need to remove the automatic redirection. In my case, I could go to Program.cs file and remove the middleware code app.UseHttpsRedirection(). Once I removed the redirection code, I published the code for deployment again.
Once deployed the new code, again I tried to run the application using dotnet WebUi.dll command where WebUi.dll is my application file. I got the same message as the appliction running on ports 5000 and 5001. The port 5000 for HTTP calls and the port 5001 for HTTPS calls.
This time when I ran the CURL command with http://localhost:5000 URL, I could see the HTML file of my application. That means my application running with the Kestrel server.
If the user wants to test the application after deployment with HTTP, the user can remove the automatic redirection middleware. Otherwise, the user has to set up the HTTPS with an SSL certificate (it can be fake or proper). In my case, I just wanted HTTP calls so I removed automatic redirection middleware from the code.