Blazor server App aborting on not finding _framework/blazor.web.js

Balu Raju 81 Reputation points
2024-02-08T22:27:47.5833333+00:00

We upgraded our Blazor server app to .Net 8 from .Net 6. by folowing the instructions. we changed the blazor.server.js to blazor.web.js. everything works good from visual studio IDE using IIS express. After the application is deployed to our test server, we get the error GET https://my domain.com/_framework/blazor.web.js net::ERR_ABORTED 404 (Not Found). I swtiched to see blazor.server.js works or not, I get a different error. I have installed the nuget package Microsoft.aspnetcore.component.web(8.0.1) and referenced to the project. Any help is appreciated.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,665 questions
{count} votes

Accepted answer
  1. AgaveJoe 29,946 Reputation points
    2024-02-09T16:16:17.61+00:00

    it was deployed in sub directory

    See the docs for how to configure a Blazor application deployed to an IIS sub application. App base path

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Balu Raju 81 Reputation points
    2024-02-09T13:13:53.7766667+00:00

    Hi, It works well in VS IDE, but when hosted on the server in IIS, it does not work as it could not find the resource blazor.web.js.

    0 comments No comments

  2. Balu Raju 81 Reputation points
    2024-02-09T14:06:41.5933333+00:00

    Here is what I did, I created a brand new Blazor Web App with .Net 8 using the "Blazor Web App" template. No changes were made. I took the application as it was created. Worked well in IIS Express locally via VS IDE. Published it and deployed on our Test IIS Server. I'm getting the same Resource not found on many things. User's image

    Here is my generated APP.razor code <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <base href="/" /> <link rel="stylesheet" href="bootstrap/bootstrap.min.css" /> <link rel="stylesheet" href="app.css" /> <link rel="stylesheet" href="TestBlazorWebApp.styles.css" /> <link rel="icon" type="image/png" href="favicon.png" /> <HeadOutlet @rendermode="InteractiveServer" /> </head> <body> <Routes @rendermode="InteractiveServer" /> <script src="_framework/blazor.web.js"></script> </body> </html>


  3. Balu Raju 81 Reputation points
    2024-02-09T14:39:16.68+00:00

    I think the issue is in app.razor code that I pasted in my previous reply. the line that causes the issue is <base href="/" /> In localhost the url is https://localhost:<port number/ whereas when I deployed. it was deployed in sub directory https://mysite.com/myDir so, when I changed in the App.Razor <base href="/myDir/" />. it worked. Prior to upgrade I used to have this <base href="~/" />, it seemed to work, but not anymore. I cannot hard code the sub directory in the app razor because production deployment could be any folder. Any suggestions?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.