Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

389
Visualizações
Microsoft.JSInterop.JSException: Could not find 'browserInterop.getPropertyRef' ('browserInterop' was undefined) - in Blazor

I am having an issue in my blazor application with the JS Interop. The method is for a pop up to allow to access users location for a weather API call but if its a users first time hitting the site it crashes...but if refreshed it all works fine and if the users exists it works fine aswell here is the method and it being called. Would appreciate any input.

Method:

public async Task GetUserLocation()
    {
        try
        {
            //Ask user access to geolocation
            var window = await jsRuntime.Window();
            var navigator = await window.Navigator();
            GeolocationWrapper = navigator.Geolocation;
        }
        catch (Exception)
        {
            throw;
        }

        //Gets current Geolocation
        CurrentPosition = await GeolocationWrapper.GetCurrentPosition();

        //Lattitude coords
        UserLocaion.Lat = CurrentPosition.Location.Coords.Latitude.ToString("0.00");
         
        //Longitude coords
        UserLocaion.Lon = CurrentPosition.Location.Coords.Longitude.ToString("0.00");
    }

called here:

protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            // Gets coordinates from geolocation using IJSRuntime Geoloaction navigator
            await GetUserLocation();

            //Gets data from Open Weather API
            OPW_WeatherData = await iOPW.GetWeatherData(UserLocaion.Lat,UserLocaion.Lon);

            //Gets the forecast for the week 
            WeeksForecast = iOPW.GetWeeksForecast(OPW_WeatherData);

            //Get todays weather
            TodaysWeather = iOPW.GetTodaysWeather(OPW_WeatherData, WeeksForecast);

            //Sets the Timezone of the current User
            TimeZone = OPW_WeatherData.Timezone;

            StateHasChanged();
        }
    }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda