Replace UseStaticFiles() with MapStaticAssets() in Blazor Maui Web template#31618
Replace UseStaticFiles() with MapStaticAssets() in Blazor Maui Web template#31618mattleibow merged 3 commits intomainfrom
Conversation
…mplate Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
There was a problem hiding this comment.
Done. Reverted the unrelated changes to this templatestrings.json file. All templatestrings.json files have been restored to their original state in commit 4536815.
…files Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the Blazor MAUI Web template by replacing the legacy UseStaticFiles() middleware with the newer MapStaticAssets() approach for serving static assets in ASP.NET Core applications.
Key changes:
- Removes
app.UseStaticFiles()call from the middleware pipeline - Adds
app.MapStaticAssets()call positioned beforeMapRazorComponents() - Updates the template to follow current ASP.NET Core best practices
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
This PR updates the Blazor Maui Web template to use the modern ASP.NET Core
MapStaticAssets()middleware instead of the legacyUseStaticFiles()middleware.Changes Made
In
src/Templates/src/templates/maui-blazor-solution/MauiApp.1.Web/Program.cs:app.UseStaticFiles();callapp.MapStaticAssets();call placed beforeMapRazorComponents()Benefits
MapStaticAssets()is the recommended approach for serving static assets in modern ASP.NET Core applications as it:Testing
dotnet new maui-blazor-webFixes #31617.
Progress
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.