Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 for static assets in a hosted blazor wasm client with UI Components refactored to razor classlib #42924

Open
1 task done
msschl opened this issue Jul 26, 2022 · 3 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-static-web-assets investigate
Milestone

Comments

@msschl
Copy link
Contributor

msschl commented Jul 26, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When serving the blazor framework files from a different path and moving all the UI code from a blazor wasm project into a razor class lib in preperations for MAUI, the static assets won't be served anymore.

See my example repo.

In the server the app serves the blazor framework files form /core and serves the fallback file also from /core

Server/Program.cs

app.UseBlazorFrameworkFiles("/core");
app.UseStaticFiles();

app.UseRouting();


app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("/core/{*path:nonfile}", "core/index.html");

app.Run();

In the client all files are moved to the Core razor classlib except for the csprojc, Program.cs and the index.html from the wwwroot folder. In the csprojc the StaticWebAssetBasePath tag is added with the value core.
The index.html is modified to the base /core/ and the stylesheet links are adapted to _content/BlazorApp.Core/**

Expected Behavior

Referenced razor class libs should still be able to include static web assets.

Steps To Reproduce

See my example repo.

Exceptions (if any)

No response

.NET Version

dotnet --info .NET SDK (gemäß "global.json"): Version: 6.0.400-preview.22330.6 Commit: da7c9ccceb Laufzeitumgebung: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.400-preview.22330.6\ global.json file: Not found Host: Version: 6.0.7 Architecture: x64 Commit: 0ec02c8c96 .NET SDKs installed: 6.0.302 [C:\Program Files\dotnet\sdk] 6.0.400-preview.22330.6 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Download .NET: https://aka.ms/dotnet-download Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info

Anything else?

No response

@mkArtakMSFT mkArtakMSFT added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-static-web-assets investigate labels Jul 26, 2022
@mkArtakMSFT mkArtakMSFT added this to the .NET 8 Planning milestone Jul 26, 2022
@msschl
Copy link
Contributor Author

msschl commented Aug 29, 2022

The goal is to create an asp net core server with razor pages. At a specific path (in my case /core) the wasm client application should be served. This client app also includes some razor class libs with static content. This content should be for my understanding also be served from /core. Also, the wasm app is only for authorized users.

@javiercn

Maybe this has also something to do with the MicrosoftAspNetCore.ClientAssets package. It looks like only on publish the assets are copied to the wwwroot folder.

@msschl
Copy link
Contributor Author

msschl commented Aug 29, 2022

I've also tried without modifing the base to /core
See the no_base example on net7.0 latest preview

@Eilon
Copy link
Member

Eilon commented Oct 27, 2022

Possibly related/similar to dotnet/maui#10898 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-static-web-assets investigate
Projects
None yet
Development

No branches or pull requests

5 participants