Skip to content

Consider aligning how the @page directive works in razor components with how it works in razor pages #8787

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
danroth27 opened this issue Mar 25, 2019 · 7 comments
Labels
affected-all This issue impacts all the customers area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) feature-razor.language Priority:2 Work that is important, but not critical for the release severity-nice-to-have This label is used by an internal tool

Comments

@danroth27
Copy link
Member

danroth27 commented Mar 25, 2019

The fix for this is to align the behavior of the @page directive with the Razor Pages behaviour, with one addition. If your page is in the Pages folder then that segment will be ignored.

If you don't like this, and you want direct control, you can use @attribute [Route(....)]

@danroth27 danroth27 added area-aspnet area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-blazor Includes: Blazor, Razor Components and removed area-aspnet labels Mar 25, 2019
@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Mar 26, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview5 milestone Mar 26, 2019
@mkArtakMSFT mkArtakMSFT added the Needs: Design This issue requires design work before implementating. label Mar 26, 2019
@mrlife
Copy link
Contributor

mrlife commented Mar 27, 2019

This makes a lot of sense, especially with razor components used within a razor pages web app.

@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@rynowak rynowak removed the Needs: Design This issue requires design work before implementating. label May 30, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: 3.0.0-preview8, 3.1.0 Jun 25, 2019
@rynowak rynowak removed their assignment Jul 4, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: 3.1.0, 5.0.0 Aug 12, 2019
@mkArtakMSFT mkArtakMSFT modified the milestones: 5.0.0, 5.0.0-preview1 Aug 19, 2019
@gingters
Copy link

In my opinion, for a Blazor SPA routing should not require attributes at all.
In fact, the actual component should neither need nor require to know if it is used as a page (aka has a route) or a component, or both.

Also, if you want to provide re-usable components and pages for multiple applications under different routes (i.e. in a component or functionality library), the attribute approach is extremely inflexible as you can only have one definition on the attribute, and you need to copy & paste code or unnecessarily derive a new component from the shared one to provide different routes.

It would be much better to have a configurable routing system which you set up in Startup.cs (i.e. like in Angular, where you can define what route ends up at what component).
There could be an configuration that (ideally optionally and not even by default) uses the @page and @route attributes, but usually for real-world applications you want to have explicit control about your application routing and not mix your routing logic into the components which should be as agnostic about their usage as possible.

@mrlife
Copy link
Contributor

mrlife commented Jul 31, 2020

Default and optional route parameters would be useful.

@SteveSandersonMS SteveSandersonMS added affected-all This issue impacts all the customers severity-nice-to-have This label is used by an internal tool labels Oct 6, 2020 — with ASP.NET Core Issue Ranking
@javiercn javiercn added feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) feature-razor.language labels Apr 19, 2021
@pranavkm pranavkm removed the c label Aug 16, 2021
@TanayParikh
Copy link
Contributor

@danroth27 is this something we're still looking to pursue? If so, would this be a 7.0 planning candidate?

@danroth27
Copy link
Member Author

I think it's worth trying to get to a consistent place with @page. Let's make this a 7.0 candidate.

@danroth27 danroth27 modified the milestones: Backlog, .NET 7 Planning Oct 19, 2021
@TanayParikh TanayParikh added the Priority:2 Work that is important, but not critical for the release label Oct 21, 2021
@mkArtakMSFT mkArtakMSFT modified the milestones: .NET 7 Planning, Backlog Nov 11, 2021
@ghost
Copy link

ghost commented Nov 11, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT
Copy link
Member

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affected-all This issue impacts all the customers area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) feature-razor.language Priority:2 Work that is important, but not critical for the release severity-nice-to-have This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

10 participants