New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples fail under IIS #46

Closed
rocklan opened this Issue Feb 7, 2018 · 12 comments

Comments

Projects
5 participants
@rocklan
Contributor

rocklan commented Feb 7, 2018

Samples fail on IIS

If hosting samples in IIS, they fail because there is no mime type for the WASM extension

Functional impact

Samples don't work

Minimal repro steps

  1. Open IIS
  2. Create a new site
  3. Point it towards Blazor\samples\StandaloneApp\bin\Debug\netcoreapp2.0\dist
  4. Open http://localhost in browser

Expected result

"Hello World" to be displayed

Actual result

Page is stuck on "Loading..." screen

Further technical details

By default IIS does not have a content type for WASM extension. Adding "application/wasm" for the WASM extension fixes the issue. (I note that IIS Express uses "application/octet-stream" as the mime type, but it doesn't look like there is a standard yet.)

Even more confusing, if you add the MIME type into IIS at the Site level, upon next compilation the web.config file is cleared out, and the mime type is then cleared out. It needs to be added at the server level.

Even more confusing, the error shown in the browser console is:

WASM: failed to asynchronously prepare wasm: CompileError: wasm validation error: at offset 4: failed to match magic number

Which is a bit misleading.

@SteveSandersonMS

This comment has been minimized.

Member

SteveSandersonMS commented Feb 7, 2018

Thanks for the clear info!

I expect we'll need to put in a Web.config that contains a relevant entry for wasm if we choose to support this by default.

@danroth27

This comment has been minimized.

Member

danroth27 commented Feb 14, 2018

@danroth27

This comment has been minimized.

Member

danroth27 commented Feb 14, 2018

Looks like the MIME type being registered is application/wasm. WebAssembly/spec#573

@danroth27 danroth27 added this to the 0.1.0 milestone Feb 14, 2018

@danroth27

This comment has been minimized.

Member

danroth27 commented Feb 14, 2018

I believe we'll need to address this for publishing (#16) and for our ASP.NET Core hosted project template (#118)

@danroth27 danroth27 added this to To Do in 0.1.0 via automation Feb 14, 2018

@shirhatti

This comment has been minimized.

Member

shirhatti commented Feb 14, 2018

We can add the application/wasm MIME-type in IIS going forward, but for now you'll need the WebSDK (unless there's a completely different toolchain?) to add this to the generated web.config

@shirhatti

This comment has been minimized.

Member

shirhatti commented Feb 14, 2018

@bariscaglar Here's another request to add a MIME-type to IIS

@shirhatti

This comment has been minimized.

Member

shirhatti commented Feb 14, 2018

FYI. I created an internal tracking bug (#15952188)

@bariscaglar

This comment has been minimized.

bariscaglar commented Feb 15, 2018

Can you add both requests to the same bug? I'll resolve both in one go.

@shirhatti

This comment has been minimized.

Member

shirhatti commented Feb 15, 2018

Done.

@SteveSandersonMS Can you confirm this is right?

<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
@bariscaglar

This comment has been minimized.

bariscaglar commented Feb 15, 2018

These are both static types, right?

@SteveSandersonMS

This comment has been minimized.

Member

SteveSandersonMS commented Mar 14, 2018

@shirhatti That's right! application/wasm is the correct standard MIME type for .wasm files.

@bariscaglar I'm unsure what you mean by "both", but yes application/wasm should be treated as static files. Was there another MIME type you were also asking about?

As for this issue more generally, I no longer think there's a Blazor bug here. It turns out that publishing works fine by default without needing to configure any extra MIME type, because our UseBlazor middleware serves the files with the correct Content-Type anyway. Plus when you publish a standalone app, we generate a web.config that sets up the necessary MIME types by default.

The original repro steps posted here involve pointing IIS at the unpublished dist directory. That's not going to work anyway because IIS won't see the static content under wwwroot if you do that. The correct way to use IIS is either (a) use the ASP.NET hosted template, pointing IIS to the root of the server project, or (b) point IIS to the publish output. We don't currently support using IIS for the standalone template in unpublished mode, because people wouldn't want that anyway, because then you wouldn't get the dev server features such as live reloading.

We can change any of these details in the future if we want, but I'll close this now because it no longer appears that there's a Blazor bug.

0.1.0 automation moved this from To Do to Done Mar 14, 2018

@bariscaglar

This comment has been minimized.

bariscaglar commented Mar 14, 2018

@SteveSandersonMS there was another request from elsewhere, hence "both". Nothing to worry about on your end :)

@danroth27 danroth27 added question and removed enhancement labels Mar 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment