I have created a standard ASP.NET website targeting .NET Framework and am running it in Docker using Docker-compose.
When debugging the website, none of the breakpoints in the "startup" code of the website are hit.
Breakpoints in controllers are hit as expected.
When running in IISExpress, I hit the breakpoints in startup code immediately.
To me, it seems that VS 2019 doesn't attach to the website in time for it to hit the breakpoints in the startup code.
I've tried the same thing with a ASP.NET Core website, and there the breakpoints in Program.Main()-method are hit immediately.
I have tried setting the Docker-compose "Launch Action" to "Do Nothing" to avoid the website from starting up until I make a request to it, but with no luck.
Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-1803
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
Docker-compose.yml:
version: '3.4'
services:
mydockerizedwebapp:
image: ${DOCKER_REGISTRY-}mydockerizedwebapp
container_name: mydockerizedwebapp
build:
context: .\MyDockerizedWebApp
dockerfile: Dockerfile
Docker-compose.override.yml:
version: '3.4'
services:
mydockerizedwebapp:
ports:
- "80"
networks:
default:
external:
name: nat
Does anyone know how to attach the Visual Studio debugger in time for me to hit breakpoints in the startup code?
Edit:
If an exception occurs in the startup of the web site, so that it goes down, then the next request to the webserver will "reboot" it, and the breakpoints are hit. But why don't they hit the first time around?