Maybe these links will be helpful:
https://github.com/dotnet/aspnetcore/issues/15765
https://github.com/mono/mono/issues/8007
I've never tried this, but it sounds like you might have some luck if you compile it to WebAssembly first, then invoke it through JS Interop. These links are kind of old though, so things could have changed.
Also, if this doesn't help, it may be easier for someone to answer if you provide the error message. If you're not seeing a detailed error message, you can adjust your Program.cs file to display detailed errors
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseSetting(WebHostDefaults.DetailedErrorsKey, "true");
});