Search code examples
.net-coreblazor-webassemblyblazor-client-sidekestrel-http-server

How dotnet.exe serves blazor web assembly files


Can someone explain or refer to a document on how a blazor web assembly app is served by dotnet.exe process?

So here is what I have done and what I know.

  • Scaffolded a new blazor web assembly project using the command dotnet new blazorwasm -o BlazorTest.
  • Ran the project using the command dotnet run and it runs as expected.

Remember I am not using the --hosted parameter to include ASP.NET Core server.

As far as my understanding goes, the output of blazor web assembly project are set of static files which run inside of a browser process. In order for these files to run inside of a browser we need a web server like kestrel/iis or a cdn to serve these files.

Now my question is, in the current setup where is that webserver or cdn present which is required to serve the files?


Solution

  • The dotnet CLI is reading your Properties\launchSettings.json file.

    The default profile launches the app using IIS Express.

    If you want use the other Kestrel launch profile that is included in the template, you can use:

    dotnet run --launch-profile "BlazorTest"
    

    Note: The "project" profile will be scaffolded as the name of the app you specified in dotnet new