dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.56k stars 10.05k forks source link

Blazor IViewLocalizer through Exception if Key doesn't exists #58069

Open khallid-itdevtech opened 2 months ago

khallid-itdevtech commented 2 months ago

Is there an existing issue for this?

Describe the bug

I am using Blazor Components inside .Net8 MVC Web Application. I am using IViewLocalizer inside razor views it works fine but when i use IViewLocalizer inside Blazor Components if Key doesn't exists it throughs Exception

Expected Behavior

IViewLocalizer should work same as .Net8 MVC Razor views / pages. Return the Key if locale string doesn't find @inject IViewLocalizer Localizer Localizer["Khalid"] doesn't give exception in .Net8 MVC where as in Blazor components if throughs exception

Steps To Reproduce

No response

Exceptions (if any)

NullReferenceException: Object reference not set to an instance of an object. Microsoft.AspNetCore.Mvc.Localization.ViewLocalizer.get_Item(string key)

.NET Version

.Net8

Anything else?

No response

dotnet-policy-service[bot] commented 2 months ago

Looks like this issue has been identified as a candidate for community contribution. If you're considering sending a PR for this issue, look for the Summary Comment link in the issue description. That comment has been left by an engineer on our team to help you get started with handling this issue. You can learn more about our Help Wanted process here