Skip to content
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

Adding feature to Router for custom language URL #40736

Open
1 task done
emir3100 opened this issue Mar 16, 2022 · 3 comments
Open
1 task done

Adding feature to Router for custom language URL #40736

emir3100 opened this issue Mar 16, 2022 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-routing Features related to routing in Blazor applications feature-blazor-server Priority:2 Work that is important, but not critical for the release
Milestone

Comments

@emir3100
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.

Im using blazor server and when I am trying to implement a language url to my website, I run into problems with the router component.

I tried to modify the current router but many of the classes are protected and inaccessible.

https://example.com/home --> https://example.com/en/home
My desired outcome is to use @page "/home" on the pages without adding the language code.

Describe the solution you'd like

Either implement a feature to easier create language URL with the router component or make it easier to modify the current router.

Additional context

No response

@mkArtakMSFT mkArtakMSFT added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing labels Mar 16, 2022
@Alerinos
Copy link

                endpoints.MapGet("/{culture:regex(^[a-zA-Z]{{2}}(-[a-zA-Z+]{{2}})?$)=pl}/{**rest}", async context =>
                {
                    var culture = context.Request.RouteValues["culture"] ?? _website.Culture;
                    var rest = context.Request.RouteValues["rest"];

                    var option = new CookieOptions
                    {
                        Expires = DateTime.Now.AddYears(1)
                    };
                    context.Response.Cookies.Append("Culture", culture.ToString() ?? "", option);

                    context.Response.Redirect($"/{rest}", permanent: false);

                    await Task.CompletedTask;
                });

The only thing you can do is redirect the URL to the cookie. Routing in blazor is very weak.

@javiercn javiercn added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Mar 17, 2022
@javiercn
Copy link
Member

Tracking as part of #38121

@ghost ghost locked as resolved and limited conversation to collaborators Apr 16, 2022
@danroth27 danroth27 removed the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Nov 17, 2022
@danroth27
Copy link
Member

danroth27 commented Nov 17, 2022

Reopening so we can independently consider this link generation scenario.

@danroth27 danroth27 reopened this Nov 17, 2022
@danroth27 danroth27 added area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Nov 17, 2022
@mkArtakMSFT mkArtakMSFT added this to the .NET 8 Planning milestone Nov 17, 2022
@mkArtakMSFT mkArtakMSFT added triaged feature-blazor-server feature-blazor-routing Features related to routing in Blazor applications Priority:2 Work that is important, but not critical for the release and removed feature-routing labels Nov 17, 2022
@mkArtakMSFT mkArtakMSFT modified the milestones: .NET 8 Planning, Backlog Jun 29, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, BlazorPlanning Nov 5, 2023
@mkArtakMSFT mkArtakMSFT removed this from the Planning: WebUI milestone Nov 26, 2023
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Nov 26, 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 enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-routing Features related to routing in Blazor applications feature-blazor-server Priority:2 Work that is important, but not critical for the release
Projects
None yet
Development

No branches or pull requests

5 participants