Skip to content

Allow @page directive in Razor Components to accept constant strings #7519

Open
@hellfirehd

Description

@hellfirehd

Currently the @page directive must specify a route template. The route template must be enclosed in quotes and begin with the '/' character.

I need to be able to use a const string as well.

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

I want to define my routes in a single place and then reuse them throughout the application, eliminating as many string literals as possible. Without this, refactoring and long-term maintenance becomes a nightmare of Find/Replace.

Describe the solution you'd like

Ideal:

@page @ClientRoutes.Members.ClinicalSupervision

Acceptable:

@page "@ClientRoutes.Members.ClinicalSupervision"
public static class ClientRoutes
{
	public static class Members
	{
		public const string ClinicalSupervision = "/Members/ClinicalSupervision";
	}
}
...

private void CancelAsync() => NavigationManager.NavigateTo(ClientRoutes.Members.ClinicalSupervision);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions