Skip to content

[Blazor] strongly defined page path and also default page path #41827

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
janseris opened this issue May 24, 2022 · 3 comments
Closed
1 task done

[Blazor] strongly defined page path and also default page path #41827

janseris opened this issue May 24, 2022 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-routing Features related to routing in Blazor applications ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@janseris
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I am trying to avoid typos in NavMenu component.
Currently, every page has @page "path"

The convention is "camelCase"

When using href in NavMenu, I could use nameof(TheBlazorPageClass) but that yields a PascalCase name. I have to use an extension function/helper method to get camelCase.

And on the page, I have to manually specify the path. There is no default.

Describe the solution you'd like

  1. make default page path without specifying the string
  • e.g. @page in a BlazorPageClass would be automatically "/blazorPageClass"
  1. allow expression to specify a custom @page path
  • e.g. @page @($"/{this.GetType().Name}") -> would return"/BlazorPageClass" and the same can be used in NavMenu href
  • this avoids typos

Additional context

No response

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label May 25, 2022
@javiercn javiercn added the feature-blazor-routing Features related to routing in Blazor applications label May 25, 2022
@javiercn
Copy link
Member

@janseris thanks for contacting us.

  1. make default page path without specifying the string

We already have an issue for this. That said, we wouldn't do any camel casing of the url or any other transformation to the URL.
#8787

  1. allow expression to specify a custom @page path

This is not possible with our current Routing system, and it is very unlikely it'll ever be possible unless we drastically redesign how it works, which we don't have plans to.

Routes are encoded as attributes and attributes can't contain expressions like the ones you want.

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels May 25, 2022
@ghost ghost added the Status: Resolved label May 25, 2022
@janseris
Copy link
Author

@javiercn

  1. Thanks, I remembered that feature from razor pages/MVC just as seen in that issue - the page has default path unless specified I think.
  2. Okay, thank you for info.

@ghost
Copy link

ghost commented May 26, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed May 26, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 25, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-routing Features related to routing in Blazor applications ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants