Jan Krüger
✅ Getting Error 400: Invalid Hostname when trying to access application in Docker container
Hello, I have a .net 7 application running inside a Docker container. The .NET application has an endpoint to generate PDFs of a Razor site.
It is using pupeteer to generate the pdf, so it needs to access its own page:
I'm trying to access the page using localhost:
http://localhost:80/api/...
That works without any flaws when running the application outside of the docker container during development, but once its deployed it nolonger works.
I'm receiving 400: Invalid Hostname
errors when the headless chromium tries to access localhost.
I also tried curling from within the container to localhost and get the same response:
My Program.cs looks like this:
Inside my Startup I never set any specific host.
I do set the AllowedHosts
through my AppSettings tho:
That results in the application listening on Now listening on: http://[::]:80
which is what I expect.
Just for completeness here is my dockerfile:
4 replies
Return NotFound with details
Hello. I have a asp.net core Web API with controllers and I want to return for example a NotFound Error with a custom message attached, that I can then show to the user.
This for example creates a problem, so the format that I want:
But when I add a message to the ActionResult I only get a
text/plain
message:
Does someone have an idea, what is going on?12 replies