Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!