Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS Express vs dotnet run [duplicate]

Actually I understand that IIS Express is lightweight development server. From the other side "dotnet run" runs the application as a console application and binds it to random port.

But what is the actual difference? I can launch big enterprise application by IIS Express and by "dotnet run" and both cases work perfectly.

Till now all the difference I see is that IIS Express adds icon to the taskbar and dotnet run allows to see console output. But those are minor differences. It should be some global ones why IIS Express is so widespread nowadays.

Some structurization can be found here: ASP.NET Core launch settings: IIS Express, IIS, Project, Executable. But it still doesn't explain the difference.

like image 572
Alex Vovchuk Avatar asked Feb 12 '20 21:02

Alex Vovchuk


1 Answers

dotnet run will use the embedded Kestrel server. IIS Express will use IIS Express as a reverse proxy which calls Kestrel behind the scenes. In either case a server is hosting your app.

You can toggle your local server choice by adjusting the run configuration. IIS Express will use...IIS Express. But if you instead select the project (in the case of the screenshot, it's titled weatherapi) it will use Kestrel instead. You'll see a command prompt pop up, showing some basic configuration data (assuming you haven't changed the default logging output). The first time it's run, you may have to accept/install the localhost TLS certificate, so that you don't run into TLS errors.

enter image description here

One way of confirming which process you are using, is to call get-process in powershell, along with either iisexpress or {nameOfProject}

enter image description here

More info from the docs https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/?view=aspnetcore-3.1&tabs=windows

like image 184
petah Avatar answered Oct 27 '22 22:10

petah