Ahmad
Ahmad

Reputation: 12737

How can I host a blazor app within a virtual app folder and still be able to run it in IIS express?

I am developing a Blazor Server Side app using .Net 8 Core.

When I run the application from Visual Studio (while in development), the app is mapped to localhost:someportnumber (using IIS Express)

Once the development is completed, the app is published to a real server (let's say the hostname of the server is web-app-server-1.

The server already has a default web site setup and running at https://web-app-server-1/

Therefore, I created a virtual app within the running site, and host all of the published files from the blazor app into it. The virtual app is using its own Pool so that it may not compete with the main site allocated resources.

Let's assume the virtual app is mapped to htts://web-app-server-1/myapp/

The app works, but none of the NavLink components point to the correct routes (they lead to the main site). Also the css, javascript is loading properly, because for some reason, they are expected to be located within the contents of the main site.

I can edit App.razor to modify the line <base href="/" > to be <base href="/myapp"> and that will fix the css and javascript, and all of the NavLink components, but that change will break the development environment. Meaning, I can no longer run the app on the development machine, since localhost:somerandomport/myapp will report a 404 page.

How can I solve this problem?

Upvotes: 3

Views: 422

Answers (0)

Related Questions