Blazor in Internet Explorer

Support for asm.js was intentionally removed from Blazor in this commit: https://github.com/aspnet/Blazor/commit/4006cd543900fcc1cf76cd75a1b24007e60c8a67 . If I understand correctly, getting asm.js support back from stock blazor would require the mono project to start including an asm.js build in its binary distribution and for the Blazor project to add that back to its build/deploy tooling.

I haven’t tried it, but it might be possible to build mono for asm.js yourself and inject it into your built Blazor application as part of your own deploy process.

If I understand correctly, Blazor still runs using mono’s interpreted mode, so supplementing the wasm build of mono with an asm.js one might still be sufficient. If Blazor switches to actually compiling assemblies to wasm directly in the future, things will become more complicated.

Alternatives

Blazor supports server-side hosting mode. You already mentioned this in your question, but I am discussing this here in case others skipped over that. In server hosting mode, the client only needs to be able to run “traditional” JavaScript (though it may need polyfills). This can be made to work in IE11 and other clients lacking wasm support. Of course, this takes more resources on the server, prevents the client from supporting offline scenarios, and is basically like a glorified telnet session. But this may be sufficient for LOB applications.


WebAssembly is not included in Internet Explorer features. You can learn about browser compatibility at mozilla.org, and no, IE has no support for WebAssembly.

enter image description here

Remember IE is discontinued, but still maintained:

Will Internet Explorer 11 continue to receive updates?

The latest features and platform updates will only be available in Microsoft Edge. We will continue to deliver security updates to Internet Explorer 11 through its supported lifespan. To ensure consistent behavior across Windows versions, we will evaluate Internet Explorer 11 bugs for servicing on a case by case basis.

Changing from WebAssembly to component mode is just a few lines change code, but seems weird to deploy both modes to keep compatibility for IE. Remember Blazor is experimental, I guess for a real deployment you should to wait for a while... time to update from IE to some other browser.

Is there really way how to correctly fall back to asm.js mode in (only) Internet Explorer?

I guess is the same question as "How can I check if a browser supports WebAssembly?", just adapt the answer for Blazor:

const isClientSideWebAssemblySupported = (() => {
    try {
        if (typeof WebAssembly === "object"
            && typeof WebAssembly.instantiate === "function") {
            const module = new WebAssembly.Module(
                               Uint8Array.of(0x0, 0x61, 0x73, 0x6d,
                                             0x01, 0x00, 0x00, 0x00));
            if (module instanceof WebAssembly.Module)
                return new WebAssembly.Instance(module) 
                           instanceof WebAssembly.Instance;
        }
    } catch (e) {
    }
    return false;
})();

var script = document.createElement('script');
script.src = (isClientSideWebAssemblySupported)?
             "_framework/blazor.server.js":
             "_framework/blazor.webassembly.js";

Remember to include both js in your project.