目次
文書の過去の版を表示しています。
Blazor - Web ブラウザで動作する .NET Core 環境
参考文献
Using Roslyn in wasm-Project · Issue #11066 · mono/mono · GitHub
GitHub - Suchiman/Runny: Prototype of running roslyn in the browser via Blazor
トラブルシューティング
サブディレクトリで Blazor アプリが動作しない
テンプレートのアプリは <base href=“/” /> になっているので、配置する階層に合わせて修正する。
ここでは、<base href=“/media/dotnet/core/blazor_app/” /> に配置するように修正している。
これを適切に修正しないと、blazor.webassembly.js の fetch API 呼び出しなどがすべてサブディレクトリを無視して https://www.tomoyan.net/_framework/ へ要求してしまい 404 Not Found となってしまう。
- index.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width"> <title>blazorapp</title> <base href="/media/dotnet/core/blazor_app/" /> <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /> <link href="css/site.css" rel="stylesheet" /> </head> <body> <app>Loading...</app> <script src="_framework/blazor.webassembly.js"></script> </body> </html>
「Incorrect response MIME type. Expected 'application/wasm'.」が発生する
WASM: wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'. blazor.webassembly.js:1 WASM: falling back to ArrayBuffer instantiation blazor.webassembly.js:1 WASM: Initialized blazor.webassembly.js:1
Web サーバの mime.types に application/wasm wasm を追加する。
$ sudo vi /etc/mime.types
- /etc/mime.types
x-conference/x-cooltalk ice x-epoc/x-sisx-app sisx application/wasm wasm
設定を反映させるために Apache をリロードする。
$ sudo systemctl reload httpd