I have an ASP.NET Core 5 web app.
I noticed if I run it using the project name, DutchTreat, the breakpoint in my Main() method is hit immediately.
However if I run using IIS Express, the Main() method's breakpoint only gets hit when I initiate an HTTP request.

Why is this?
What code is actually running when I start the app using IIS Express but before I make an HTTP request?

Also, why does IIS Express use completely different port numbers for HTTP and HTTPS, whereas when using the project name, it uses 5000 and 5001?
IIS:

Project name:

For Asp.net core, there is a self-hosted application named Kestrel. It's a web server that handles requests/responses. In this case, IIS/IISExpress acts as a proxy and application activator.
If you start your web application by running your app (DutchTreat) directly, the Kestrel server is started (Main() runs) and listens for HTTP requests.
Otherwise, if you run your app with IIS/IISExpress, IIS will add a reference to the application (UrlRewrite in web.config). When an HTTP request comes, IIS will trigger the running of your application (.exe) and then the Main() method will be executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With