Skip to content

ASP .NET 8 RC2 Routing & UseStaticFiles #51677

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

Closed
1 task done
1619digital opened this issue Oct 26, 2023 · 3 comments
Closed
1 task done

ASP .NET 8 RC2 Routing & UseStaticFiles #51677

1619digital opened this issue Oct 26, 2023 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@1619digital
Copy link

1619digital commented Oct 26, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This is the same bug as #50707 , except when using an Additional Assembly. That is, with an optional parameter in the route, the app is unusable, because all requests to static assets get routed the to the blazor page, not the static asset.

Changing the page directive from @page "/{PageName?}" to @page "/" fixes the issue.

I have tried this on rc2 and nightly.

Steps To Reproduce

repository here - https://github.com/OpenEnergyGroup/BlazorApp4

.NET Version

8.0.100-rtm.23526.1

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Oct 26, 2023
@javiercn
Copy link
Member

@1619digital thanks for contacting us.

The behavior you are observing is by design. /{PageName?} will match the root / and any other URL that has a single segment since you have an unconstrained parameter on it, and at that point static files will not do anything.

You need to use the {page:nonfile?} constraint if you want to avoid matching URLs that look like a file.

@javiercn javiercn changed the title ASP .NET 8 RC2 Routing & UseStaticFiles with Additional Assembly ASP .NET 8 RC2 Routing & UseStaticFiles Oct 27, 2023
@1619digital
Copy link
Author

1619digital commented Oct 27, 2023

Hi - thanks very much - is it the expected design that static files are lower down in priority than optional routes? That's not be behaviour we see with our 7.0 app, where all static files are matched before trying to match a route.

Your fix does work though (although wouldn't, I think, if you had an extension-less file) - I suggest this issue could be added to breaking changes.

@mkArtakMSFT
Copy link
Contributor

We don't plan to document this as a breaking-change, as Blazor Web is a somewhat new model, and this behavior is unique to Blazor Web.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. label Nov 2, 2023
@ghost ghost added the Status: Resolved label Nov 2, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants