-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Suggestion] Make DefaultLinkGenerator public and non sealed #25121
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
Comments
@BrightSoul thanks for contacting us. We don't tend to make classes like that available since they are focused on implementation details and greatly limit our ability to evolve the codebase. There is an IOutboundRouteParameterTransformer feature that I think you could probably use for this. |
@javiercn Thanks for your reply
Unfortunately this option was ruled out in this other issue. The thing is, I need to know what the CultureInfo for the current request is to change the I found no other extension point in ASP.NET Core that allows me to translate URLs.
Why is that though? |
Just to clarify it further. When I write this code in a Razor View:
The output should be this for an english user:
And this for an italian user:
This is an application I made which shows the workarounds I had to take to make it work. |
Thanks for contacting us. |
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. |
This is again issue related to ambient values handling with endpoint routing changed in 3.0. |
Until @javiercn solves this in .NET 7 (please please) I have this abomination as workaround. At the end of your
It removes `DefaultLinkGenerator`` from DI and installs our own implementation. Then add this class to your project:
This class wraps Maybe this would be idea for solving ambient values issues with endpoint routing: give some kind of hook for users to decide? Most complains about ambient values handling change is about multi-tenant (so urls like |
@MichalSznajder Hope in .NET 7 it's fixed/has a nice way to deal with this. |
Thanks for contacting us. |
Hi everyone,
I'd like to localize URLs of my application and, in order to do that, my solution is to translate route values for
action
andcontroller
before they're actually processed by theDefaultLinkGenerator
. This is what I'd like to do:Since I don't want to change the default url generation logic, I thought this was a simple and effective solution.
It's not viable though, since the
DefaultLinkGenerator
is aprivate sealed
class.Is there a particular reason why it cannot be a normal, overridable public class?
The fact it's a
private sealed
class did not stop me from achieving this solution, in fact I just had to wrap theDefaultLinkGenerator
with my own implementation. It works but it's way uglier.In Startup.ConfigureServices:
Would you please consider to make the
DefaultLinkGenerator
public and non-sealed?Thanks.
P.S. Overall, I've found maaaany obstacles when trying to localize URLs. Another is in issue #16965. It's almost like you didn't even consider people might want to do it.
The text was updated successfully, but these errors were encountered: