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

116
Visualizações
Html base href rewriting get first 404 after 200

I have a blazor app under the sub directory of an site on IIS. To fix blazor wasm base path problem, applied javascript code below in the head tag (suggested on elmah.io: https://blog.elmah.io/how-to-fix-blazor-wasm-base-path-problems/)

<!-- omitted for clarity -->
<head>
  <base />
  <script>
      var path = window.location.pathname.split('/');
      var base = document.getElementsByTagName('base')[0];
      if (window.location.host.includes('localhost')) {
          base.setAttribute('href', '/MyApp/');
      } else if (path.length > 2) {
          let href = '/' + path[1] + '/MyApp/';
          base.setAttribute('href', href);
      } else if (path[path.length - 1].length != 0) {
          let fullpath = window.location.origin + window.location.pathname + '/' + window.location.search;
          window.location.replace(fullpath);
      }
  </script>
</head>

It works pretty well and solve the blazor base path problem. But, when you enter the app url without ending with '/', the developer console fills up with 404 (not found) errors and then all of them turns out 200 (ok) ok for all css/js files. Why is it do that and can i fix it?

console In the network view all of resources get first 404 after 200

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