I created a standard blazor web assembly from VS 2022 from the template. It needs to run in a windows service using https. All source code is located here:
https://github.com/dgxhubbard/BlazorServiceApp
I kept getting errors, about code formatting and the hyperlinks, and after several attempts to re-format the code and links I gave up. CTRL+K nor tick marks etc worked. So I am going to give links to the code and articles instead.
Instructions for adding the code to run as a service came from this article:
https://code-maze.com/aspnetcore-running-applications-as-windows-service/
Then I needed a certificate to use for https. I added code in project GenerateCert to do this and followed this article:
for asp.net core to use the certificate. I also used this question as a source for the code:
The Blazor Server code:
https://github.com/dgxhubbard/BlazorServiceApp/blob/main/BlazorServiceApp/Server/Program.cs
Code to generate a certificate:
https://github.com/dgxhubbard/BlazorServiceApp/blob/main/GenerateCert/Program.cs
After compiling I ran GenerateCert and copied blzcert.pfx and blzcert.cer to the blazor server bin directory. Then I opened a command prompt and switched to the blazor server bin directory and ran the command to enable the blazor server to run as a service:
sc create api binPath="ServerBinPath\BlazorService.exe"
and then started the service:
sc start api
and the service was running. Then I opened chrome and went to the url for the server https://localhost:7224. And chrome generates a 404. For testing not as a service I had already opened the chrome Advanced and clicked proceed to localhost. So I am not sure why I am getting a 404 when running as a service. Where have I gone wrong here?
Also note I have looked at this question as well but it did not resolve my issue: