Have a Web Forms app that I would like to gradually port, on a page by page basis, to Blazor WebAssembly by embedding Blazor into Web Form pages the way it is possible with Angular.
Published the Blazor app to the Web Forms project under a subdirectory called "Blazor". If I run the Web Forms app and hit http://localhost:1234/Blazor the Blazor app runs fine (after editing the Blazor index.html => <base href="/Blazor/" />
). However, when I try to embed Blazor in a Web Form page it doesn't work. The web form page asp:content contains what the Blazor index.html page contains:
<%@ Page Title="EmbedTest" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="EmbedTest.aspx.cs" Inherits="WebFormBlazor.EmbedTest" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<app>Loading...</app>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">????</a>
</div>
<script src="/Blazor/wwwroot/_framework/blazor.webassembly.js"></script>
</asp:Content>
When I go to http://localhost:1234/EmbedTest the page displays: Loading... An unhandled error has occurred. Reload ????
And in the console the following error message: Uncaught SyntaxError: Unexpected token '<' blazor.webassembly.js:1
This approach does work with Angular. What am I missing in trying to do this with Blazor WebAssembly?
Update: As per Mister Magoo, it was not downloading blazor.webassembly.js but actually downloading the index.html which explains the error message.
Changed the path in the page from /Blazor/wwwroot/_framework/blazor.webassembly.js to /Blazor/_framework/blazor.webassembly.js in the Web Form page and now downloads the script but experiences new error. Gives 404 Not Found for blazor.boot.json.
Blazor.webassembly.js doesn't know the base href should be /Blazor/ and tries to fetch blazor.boot.json from localhost:1234/_framework/blazor.boot.json instead of localhost:1234/Blazor/_framework/blazor.boot.json.
So next issue: How to tell blazor.webassembly.js that its base href should be something other than '/' (in my case '/Blazor/')?
blazor.webassembly.js
file get served correctly? (My guess is no because the path looks odd - remove wwwroot) - Mister Magoo