Skip to content

Localized views with Razor Pages #40186

Open
@msschl

Description

@msschl

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.

Bringing #4873 Localized views with Razor Pages back to discussion for .net 7.0

In Razor Pages, we can inject IViewLocalizer to work with localized resources - good. But sometimes, especially on content-heavy, rather static pages, it would be nice to have location specific views, i.e. MyPage.en.cshtml and MyPage.de.cshtml etc.

My expection was that once I configure AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix, ...) Razor Pages also would be resolved by their base name, but I quickly realized there might be a problem with how the corresponding PageModel should be used/resolved. I couldn't get this to work at all - is this scenario even supported with Razor Pages?

In any case, I think the corresponding docs should be more explicit about what's possible with Razor Pages and potential limitations.

Describe the solution you'd like

View location expanders should apply to Razor pages too.

Additional context

@DamianEdwards @rynowak @pranavkm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions