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

424
Visualizações
Blazor JSInterop intermitant fail - Could not find ''

Every so often, when i load my page, i get this error, which stops my page from working.. Weird as i can load the page, 3-4 times and everything is fine, but when i try and refresh my page in quick succession i get this error..

STACK - Microsoft.JSInterop.JSException: Could not find 'search' ('search' was undefined). Error: Could not find 'search' ('search' was undefined). at http://localhost:26661/_framework/blazor.server.js:1:67390 at Array.forEach () at e.findFunction (http://localhost:26661/_framework/blazor.server.js:1:67350) at v (http://localhost:26661/_framework/blazor.server.js:1:69092) at http://localhost:26661/_framework/blazor.server.js:1:70038 at new Promise () at e.beginInvokeJSFromDotNet (http://localhost:26661/_framework/blazor.server.js:1:70011) at http://localhost:26661/_framework/blazor.server.js:1:26293 at Array.forEach () at e.invokeClientMethod (http://localhost:26661/_framework/blazor.server.js:1:26263) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at

Interop call -

protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            try
            {
                await Js.InvokeVoidAsync("search");
            }
            catch (Exception e)
            {
                ErrorIsHidden = false;
                ErrorDescription = e.ToString(); //Show error description on page
                StateHasChanged();
                throw;
            }
            
        }

JS -

function search(){$(document).ready(function () {
    $("#myInput").on("keyup", function () {
        var value = $(this).val().toLowerCase();
        $('div[data-role="apps"]').filter(function () {
            $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
        });
    });
});}

PS.. i also thought that try-catch would allow the program to continue functioning (obviously) without the search function in this case?

ON FURTHER TESTING

This is clearly not right, but the silly thing is if i again add the JS call to the catch - the JS actually loads.. my error shows up, but the app crashes still, but the JS works (obviously because the error has been registered by then).

Strange.. Not sure what the issue is here.

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