2

I am trying to host a Blazor app via a .NET Core Web Server.I am using FileProvider.I do not know why i keep getting this error :

blazor.webassembly.js:1 WASM: wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': HTTP status code is not ok WASM: falling back to ArrayBuffer instantiation Failed to load resource: the server responded with a status of 404 (Not Found) blazor.webassembly.js:1 WASM: both async and sync fetching of the wasm failed blazor.webassembly.js:1 WASM: both async and sync fetching of the wasm failed d.printErr @ blazor.webassembly.js:1 blazor.webassembly.js:1 WASM: failed to asynchronously prepare wasm: abort("both async and sync fetching of the wasm failed"). Build with -s ASSERTIONS=1 for more info. d.printErr @ blazor.webassembly.js:1 blazor.webassembly.js:1 WASM: abort("both async and sync fetching of the wasm failed"). Build with -s ASSERTIONS=1 for more info. blazor.webassembly.js:1 WASM: abort("both async and sync fetching of the wasm failed"). Build with -s ASSERTIONS=1 for more info. d.printErr @ blazor.webassembly.js:1 localhost/:1 Uncaught (in promise) abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info. :5000/favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)

.NET Core Host Startup

public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
        }
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            IFileProvider provider = new PhysicalFileProvider(@"D:/blazor/BenchUI/dist/");

            DefaultFilesOptions options = new DefaultFilesOptions
            {
                RequestPath = "",
                FileProvider = provider,
                DefaultFileNames = new List<string> { "index-browser.html" }
            };
            app.UseDefaultFiles(options);
            app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                RequestPath = "",
                FileProvider = provider,
            });
        }
    }

Html root

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width">
    <title>BenchUI</title>
    <base href="/" />
    <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>
    <script src="Utilities.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>

Folder structure I have set the root of my fileprovider as dist but there the .NET Dll's are outside that folder .Could my root be wrong ? I do not understand what is wrong since the only error appears to be in blazor.webassembly.js,a script which is added inside the index.html.

I do not understand where to run dotnet [what dll name].dll?Do i need to publish the Client project and the run dotnet Client.dll inside it or do i need to publish the Client Server and Shared. So far i have tried with dotnet [client name of dll].dll and even `dotnet run (in the csproj location)

Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
  • Have you tried `dotnet new blazorhosted` template? – Alsein Jun 26 '19 at 08:39
  • I have tried using `dotnet run` on the `Client.dll` of the project to no avail , so i made this host project for the `dist` folder and still does not work. – Bercovici Adrian Jun 26 '19 at 09:16
  • you can publish the host project and the publish output would work properly, and you dont have to create another one for the dist – Alsein Jun 26 '19 at 09:18
  • I have used `dotnet publish -c Release [path to host project]` and i have used on that folder `dotnet Client.dll` and it does not work. – Bercovici Adrian Jun 26 '19 at 11:23
  • You need to `dotnet run` the dll in which the host project's `Main` class is. – Alsein Jun 27 '19 at 01:05

0 Answers0