Daddoon / BlazorMobile

Create full C# driven hybrid-apps for iOS, Android, UWP & Desktop with Blazor!
MIT License
413 stars 55 forks source link

Issues with 404 errors when starting the *.Blazor.Server project #193

Closed vortex852456 closed 4 years ago

vortex852456 commented 4 years ago

I want to start the *.Blazor.Server to be able to Debug things in my Blazor App. But I'm getting 404-errors on static files.

Steps to reproduce: dotnet new -i BlazorMobile.Templates::3.2.4-preview2.20160.5 dotnet new blazormobile -n TestApp open TestApp.sln set TestApp.Blazor.Server as startup project F5 (start debug) confirm dialog asking for ssl trust manually open http://127.0.0.1:5080

image

I pushed the source to https://github.com/vortex852456/BlazorMobile---TestApp

Originally posted by @vortex852456 in https://github.com/Daddoon/BlazorMobile/issues/182#issuecomment-605679687

Daddoon commented 4 years ago

@vortex852456 The fact that you have a connection error with Websocket is normal through a regular web browser if you don't have your remote native apps active (and your current server project configured properly).

However i don't understand why you don't have the CSS loading properly. Your test project you commited for me work on my computer.

Did you have any special output on Visual Studio build console ?

Daddoon commented 4 years ago

Also what is your working path ?

Daddoon commented 4 years ago

I reproduced you issue, but only when i remove the app.UseStaticFiles(); from Configure in your Startup.cs file in TestApp.Blazor.Server .

Is your .NET Core installation up to date ? Can you try install the last version here, version 3.1.3 ?

https://dotnet.microsoft.com/download/dotnet-core/3.1

When using app.UseStaticFiles everything work right for me.

vortex852456 commented 4 years ago

This is my build output:

NU1603: Xamarin.Android.GeckoView 0.1.1 depends on Xamarin.Android.Support.v7.Palette (>= 27.0.0) but Xamarin.Android.Support.v7.Palette 27.0.0 was not found. An approximate best match of Xamarin.Android.Support.v7.Palette 27.0.2 was resolved.
1>------ Build started: Project: TestApp, Configuration: Debug Any CPU ------
2>------ Build started: Project: TestApp.AppPackage, Configuration: Debug Any CPU ------
2>TestApp.AppPackage -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.AppPackage\bin\Debug\netstandard2.0\TestApp.AppPackage.dll
1>TestApp -> C:\Dev\GitHub\vortex852456\TestApp\TestApp\bin\Debug\netstandard2.0\TestApp.dll
3>------ Build started: Project: TestApp.Android, Configuration: Debug Any CPU ------
4>------ Skipped Build: Project: TestApp.iOS, Configuration: Debug iPhone ------
4>Project not selected to build for this solution configuration 
5>------ Skipped Build: Project: TestApp.UWP, Configuration: Debug x86 ------
5>Project not selected to build for this solution configuration 
6>------ Build started: Project: TestApp.Desktop, Configuration: Debug Any CPU ------
6>TestApp.Desktop -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Desktop\bin\Debug\netcoreapp3.1\TestApp.Desktop.dll
6>TestApp.Desktop -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Desktop\bin\Debug\netcoreapp3.1\TestApp.Desktop.Views.dll
3>  TestApp.Android -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Android\bin\Debug\TestApp.Android.dll
3>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
========== Build: 4 succeeded, 0 failed, 3 up-to-date, 2 skipped ==========

This is my working path: C:\Dev\GitHub\vortex852456\TestApp

app.UseStaticFiles(); is also in my Startup.cs file

I installed the latest SDK (3.1.201) and Runtime (ASP.NET Core Runtime 3.1.3) from your link and Visual Studio 2019 (16.6.0 preview 2.0).

Did you open the url http://localhost:5080/?mode=server or is there another one to open?

vortex852456 commented 4 years ago

The url for the request css static file is http://localhost:5080/css/site.css - is this correct?

vortex852456 commented 4 years ago

I will try to clone and run the TestApp on another machine - reporting back in a few minutes.

Daddoon commented 4 years ago

This is my console output when setting TestApp.Blazor.Server as statup project and asking to compile this project:

NU1603: Xamarin.Android.GeckoView 0.1.1 dépend de Xamarin.Android.Support.v7.Palette (>= 27.0.0), mais Xamarin.Android.Support.v7.Palette 27.0.0 est introuvable. Une meilleure correspondance approximative de Xamarin.Android.Support.v7.Palette 27.0.2 a été résolue.
1>------ Début de la régénération globale : Projet : TestApp.Common, Configuration : Debug Any CPU ------
1>Vous utilisez une préversion de .NET Core. Consultez https://aka.ms/dotnet-core-preview
1>TestApp.Common -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Common\bin\Debug\netstandard2.0\TestApp.Common.dll
2>------ Début de la régénération globale : Projet : TestApp.Blazor, Configuration : Debug Any CPU ------
2>BlazorMobile.Build -> index.html to server_index.cshtml done in C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor
2>TestApp.Blazor -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\TestApp.Blazor.dll
2>TestApp.Blazor (Blazor output) -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\wwwroot
2>Microsoft (R) Build Engine version 16.6.0-preview-20112-08+77da97f69 pour .NET Core
2>Copyright (C) Microsoft Corporation. Tous droits réservés.
2>
2>  TestApp.Blazor -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\blazormobile_publish\
2>BlazorMobile Build result -> App package present in C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\TestApp.Blazor.zip.
3>------ Début de la régénération globale : Projet : TestApp.Blazor.Server, Configuration : Debug Any CPU ------
3>TestApp.Blazor.Server -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor.Server\bin\Debug\netcoreapp3.1\TestApp.Blazor.Server.dll
3>TestApp.Blazor.Server -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor.Server\bin\Debug\netcoreapp3.1\TestApp.Blazor.Server.Views.dll
========== Régénération globale : 3 a réussi, 0 a échoué, 0 a été ignoré ==========
Daddoon commented 4 years ago

The url for the request css static file is http://localhost:5080/css/site.css - is this correct?

Yes

Daddoon commented 4 years ago

This is my build output:

NU1603: Xamarin.Android.GeckoView 0.1.1 depends on Xamarin.Android.Support.v7.Palette (>= 27.0.0) but Xamarin.Android.Support.v7.Palette 27.0.0 was not found. An approximate best match of Xamarin.Android.Support.v7.Palette 27.0.2 was resolved.
1>------ Build started: Project: TestApp, Configuration: Debug Any CPU ------
2>------ Build started: Project: TestApp.AppPackage, Configuration: Debug Any CPU ------
2>TestApp.AppPackage -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.AppPackage\bin\Debug\netstandard2.0\TestApp.AppPackage.dll
1>TestApp -> C:\Dev\GitHub\vortex852456\TestApp\TestApp\bin\Debug\netstandard2.0\TestApp.dll
3>------ Build started: Project: TestApp.Android, Configuration: Debug Any CPU ------
4>------ Skipped Build: Project: TestApp.iOS, Configuration: Debug iPhone ------
4>Project not selected to build for this solution configuration 
5>------ Skipped Build: Project: TestApp.UWP, Configuration: Debug x86 ------
5>Project not selected to build for this solution configuration 
6>------ Build started: Project: TestApp.Desktop, Configuration: Debug Any CPU ------
6>TestApp.Desktop -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Desktop\bin\Debug\netcoreapp3.1\TestApp.Desktop.dll
6>TestApp.Desktop -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Desktop\bin\Debug\netcoreapp3.1\TestApp.Desktop.Views.dll
3>  TestApp.Android -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Android\bin\Debug\TestApp.Android.dll
3>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
========== Build: 4 succeeded, 0 failed, 3 up-to-date, 2 skipped ==========

This is my working path: C:\Dev\GitHub\vortex852456\TestApp

app.UseStaticFiles(); is also in my Startup.cs file

I installed the latest SDK (3.1.201) and Runtime (ASP.NET Core Runtime 3.1.3) from your link and Visual Studio 2019 (16.6.0 preview 2.0).

Did you open the url http://localhost:5080/?mode=server or is there another one to open?

You don't have to write mode=server anymore it was a thing a long time ago.

vortex852456 commented 4 years ago

This is my console output when setting TestApp.Blazor.Server as statup project and asking to compile this project:

NU1603: Xamarin.Android.GeckoView 0.1.1 dépend de Xamarin.Android.Support.v7.Palette (>= 27.0.0), mais Xamarin.Android.Support.v7.Palette 27.0.0 est introuvable. Une meilleure correspondance approximative de Xamarin.Android.Support.v7.Palette 27.0.2 a été résolue.
1>------ Début de la régénération globale : Projet : TestApp.Common, Configuration : Debug Any CPU ------
1>Vous utilisez une préversion de .NET Core. Consultez https://aka.ms/dotnet-core-preview
1>TestApp.Common -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Common\bin\Debug\netstandard2.0\TestApp.Common.dll
2>------ Début de la régénération globale : Projet : TestApp.Blazor, Configuration : Debug Any CPU ------
2>BlazorMobile.Build -> index.html to server_index.cshtml done in C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor
2>TestApp.Blazor -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\TestApp.Blazor.dll
2>TestApp.Blazor (Blazor output) -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\wwwroot
2>Microsoft (R) Build Engine version 16.6.0-preview-20112-08+77da97f69 pour .NET Core
2>Copyright (C) Microsoft Corporation. Tous droits réservés.
2>
2>  TestApp.Blazor -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\blazormobile_publish\
2>BlazorMobile Build result -> App package present in C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor\bin\TestApp.Blazor.zip.
3>------ Début de la régénération globale : Projet : TestApp.Blazor.Server, Configuration : Debug Any CPU ------
3>TestApp.Blazor.Server -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor.Server\bin\Debug\netcoreapp3.1\TestApp.Blazor.Server.dll
3>TestApp.Blazor.Server -> C:\2Bee\Sources\BlazorMobile---TestApp\TestApp.Blazor.Server\bin\Debug\netcoreapp3.1\TestApp.Blazor.Server.Views.dll
========== Régénération globale : 3 a réussi, 0 a échoué, 0 a été ignoré ==========

I wonder why BlazorMobile.Build is called in your build log. In my build log this is missing.

vortex852456 commented 4 years ago

I wonder why BlazorMobile.Build is called in your build log. In my build log this is missing.

Nevermind, BlazorMobile.Build is called when I rebuild:

NU1603: Xamarin.Android.GeckoView 0.1.1 depends on Xamarin.Android.Support.v7.Palette (>= 27.0.0) but Xamarin.Android.Support.v7.Palette 27.0.0 was not found. An approximate best match of Xamarin.Android.Support.v7.Palette 27.0.2 was resolved.
1>------ Rebuild All started: Project: TestApp.Common, Configuration: Debug Any CPU ------
1>TestApp.Common -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Common\bin\Debug\netstandard2.0\TestApp.Common.dll
2>------ Rebuild All started: Project: TestApp.Blazor, Configuration: Debug Any CPU ------
2>BlazorMobile.Build -> index.html to server_index.cshtml done in C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor
2>TestApp.Blazor -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\TestApp.Blazor.dll
2>TestApp.Blazor (Blazor output) -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\wwwroot
2>Microsoft (R)-Build-Engine, Version 16.6.0-preview-20162-03+00781ad13 für .NET Core
2>Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
2>
2>  TestApp.Blazor -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor\bin\Debug\netstandard2.1\blazormobile_publish\
2>BlazorMobile Build result -> App package present in C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor\bin\TestApp.Blazor.zip.
3>------ Rebuild All started: Project: TestApp.Blazor.Server, Configuration: Debug Any CPU ------
3>TestApp.Blazor.Server -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor.Server\bin\Debug\netcoreapp3.1\TestApp.Blazor.Server.dll
3>TestApp.Blazor.Server -> C:\Dev\GitHub\vortex852456\TestApp\TestApp.Blazor.Server\bin\Debug\netcoreapp3.1\TestApp.Blazor.Server.Views.dll
========== Rebuild All: 3 succeeded, 0 failed, 0 skipped ==========
vortex852456 commented 4 years ago

Can you check your working folder permission ?

Yes, I checked them and think they are okay. I also gave full access to "everyone", did not change the behaviour.

image

Daddoon commented 4 years ago

Still have this error on the other computer ?

The weird thing is that blazor.server.js is loading properly on your project !

Are you debugging with IIS or IIS Express ?

vortex852456 commented 4 years ago

The behaviour on the other computer is the same :-/

Neither. I'm debugging by pressing F5 which is configured in the project template:

{
  "profiles": {
    "TestApp.Blazor.Server": {
      "commandName": "Project",
      "launchUrl": "http://localhost:5080/?mode=server"
    }
  }
}

How do you start the debugging?

Daddoon commented 4 years ago

I will try to update to the latest Preview of Visual Studio.

On the top, you have an arrow for the debug profil to use. Instead of the Project one, use IIS Express, and tell me if you see any difference ?

I'm updating VS to test actually with your profile.

vortex852456 commented 4 years ago

There is no IIS Express since in launchSettings.json is no IIS Express defined.

image

I kinda wonder how you got it running in IIS Express without creating the profile?

vortex852456 commented 4 years ago

Btw, thanks for your help so far :)

Daddoon commented 4 years ago

I have this option on my computer, i don't know if it's related to the fact that i checked the Use IIS during development option in Visual Studio installation.

I will try to test with the same profile when my installation is finished (downloading...)

vortex852456 commented 4 years ago

Got it running - with IIS Express the static files are loading (see https://github.com/vortex852456/BlazorMobile---TestApp/commit/40e32538ce19991196ae7cd03dbc6a30f4d08176)

Daddoon commented 4 years ago

Actually i didn't have to even set UseIISIntegration in Program.cs, just selected the profile. Maybe something is not up to date on the template if working without IIS Express ? I should compare with a fresh new Blazor app.

Daddoon commented 4 years ago

But it's a good news, you can now debug !

Maybe something in the configuration is wrong or not working anymore by default. I will compare with current regular template for Blazor in the future.

I will keep this issue open in order to check for the next release, and if people has the same issue, it will be visible.

Thanks for the report by the way !

Daddoon commented 4 years ago

I don't have reproduced your bug by testing templates. I added some example code (commented) for the next version in templates in order to make theses options more clear (if needed) if this issue occur and a workaround is needed.