(Blazor/Asp.Net 6) NavigationManager.NavigateTo not working in Firefox

Viewed 582

I recently started a new Blazor Server Project. I followed a tutorial from IAmTimCorey to implement multi-language.

When I try to navigate to my language Controller via

//query = ?culture=en-EN&redirectedUri=/?
NavigationManager.NavigateTo("/Culture/SetCulture" + query, true);

It works fine in Edge and Chrome, but Firefox just does nothing.

If I call the URL manually by typing, everything works as intended.

CultureController.cs

using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;

namespace BalzorMeetUpTest.Controllers
{
    [Route("[controller]/[action]")]
    public class CultureController : Controller
    {
        public IActionResult SetCulture(string culture, string redirectUri)
        {
            if (culture != null)
            {
                HttpContext.Response.Cookies.Append(
                    CookieRequestCultureProvider.DefaultCookieName,
                    CookieRequestCultureProvider.MakeCookieValue(
                        new RequestCulture(culture)));
            }

            return LocalRedirect(redirectUri);
        }
    }
}

I also setup Routing in Program.cs

//I'll leave the standard code out right here
RequestLocalizationOptions GetLocalizationOptions()
{
    var cultures = builder.Configuration.GetSection("Cultures")
        .GetChildren().ToDictionary(x => x.Key, x => x.Value);

    var supportedCultures = cultures.Keys.ToArray();

    var localizationOptions = new RequestLocalizationOptions()
        .AddSupportedCultures(supportedCultures)
        .AddSupportedUICultures(supportedCultures);

    return localizationOptions;
}

app.UseRequestLocalization(GetLocalizationOptions());
app.UseRouting();
app.MapControllers();

Is there anything missing? Do I have to enable a specific setting in Firefox? Sorry I' m pretty new to Blazor and didn't find anything useful.

0 Answers
Related