Reputation: 9920
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:
Upvotes: 3
Views: 835
Reputation: 437
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.
Upvotes: 3