AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

[Pre ?] Blazor startup options format

Open guardrex opened this issue 11 months ago • 3 comments

Fixes #34659

🛑 HOLD

... and note that this will need What's New coverage.

https://github.com/dotnet/aspnetcore/pull/54649 wasn't merged. It's not clear if https://github.com/dotnet/aspnetcore/issues/51611 will be worked for .NET 10.


Internal previews

📄 File 🔗 Preview link
aspnetcore/blazor/fundamentals/environments.md aspnetcore/blazor/fundamentals/environments
aspnetcore/blazor/fundamentals/logging.md aspnetcore/blazor/fundamentals/logging
aspnetcore/blazor/fundamentals/signalr.md aspnetcore/blazor/fundamentals/signalr
aspnetcore/blazor/fundamentals/startup.md aspnetcore/blazor/fundamentals/startup
aspnetcore/blazor/globalization-localization.md aspnetcore/blazor/globalization-localization
aspnetcore/blazor/host-and-deploy/webassembly/index.md aspnetcore/blazor/host-and-deploy/webassembly/index

guardrex avatar Feb 06 '25 15:02 guardrex

Reverting Host and deploy > WebAssembly (Compression section) content to unblock work in the Host and deploy node. These changes should be re-introduced after the Host and deploy work is performed.

:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"

Blazor Web App:

:::moniker-end

:::moniker range=">= aspnetcore-8.0"

html
<script type="module">
  import { BrotliDecode } from './decode.min.js';
  Blazor.start({
    webAssembly: {
      loadBootResource: function (type, name, defaultUri, integrity) {
        if (type !== 'dotnetjs' && location.hostname !== 'localhost' && type !== 'configuration' && type !== 'manifest') {
          return (async function () {
            const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
            if (!response.ok) {
              throw new Error(response.statusText);
            }
            const originalResponseBuffer = await response.arrayBuffer();
            const originalResponseArray = new Int8Array(originalResponseBuffer);
            const decompressedResponseArray = BrotliDecode(originalResponseArray);
            const contentType = type === 
              'dotnetwasm' ? 'application/wasm' : 'application/octet-stream';
            return new Response(decompressedResponseArray, 
              { headers: { 'content-type': contentType } });
          })();
        }
      }
    }
  });
</script>


:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"

Standalone Blazor WebAssembly:

:::moniker-end

:::moniker range="< aspnetcore-10.0"

html
<script type="module">
  import { BrotliDecode } from './decode.min.js';
  Blazor.start({
    loadBootResource: function (type, name, defaultUri, integrity) {
      if (type !== 'dotnetjs' && location.hostname !== 'localhost' && type !== 'configuration') {
        return (async function () {
          const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
          if (!response.ok) {
            throw new Error(response.statusText);
          }
          const originalResponseBuffer = await response.arrayBuffer();
          const originalResponseArray = new Int8Array(originalResponseBuffer);
          const decompressedResponseArray = BrotliDecode(originalResponseArray);
          const contentType = type === 
            'dotnetwasm' ? 'application/wasm' : 'application/octet-stream';
          return new Response(decompressedResponseArray, 
            { headers: { 'content-type': contentType } });
        })();
      }
    }
  });
</script>


:::moniker-end

guardrex avatar Mar 31 '25 13:03 guardrex

@Rick-Anderson @wadepickett ... Either we'll need a SiteHelp ticket on this or a force merge because the warnings for aspnetcore/blazor/host-and-deploy/webassembly/index.md here are inaccurate ...

Line 130: [Warning] HTML tag 'script' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder. Line 167: [Warning] HTML tag 'script' isn't allowed. Replace it with approved Markdown or escape the brackets if the content is a placeholder.

There are no <script> tags on the lines indicated, and all <script> tags in the markdown are code-fenced or are part of a code block.

guardrex avatar Apr 01 '25 13:04 guardrex

@Rick-Anderson @wadepickett ... Nevermind! There is something wrong with the file after all. Somehow, my backticks were stripped off of my code languages in two code blocks. I'll fix it up.

UPDATE: I see what happened here. I placed the content into a GH issue comment. To have the code appear alongside the text, I removed the backticks for the issue comment. When I went to place the content+code back into the article, I didn't add the backticks after pasting. 🙈

I'm not off to a great start here! Let's hope the day goes better! 😆

guardrex avatar Apr 01 '25 13:04 guardrex

@maraf ... Dan doesn't think Blazor.start will make the cut for .NET 10. Closing the docs PR now, which is a bit of a 😢 because it was a bit of a pain to set this up 💸.

guardrex avatar Jul 21 '25 19:07 guardrex

I'm sorry for that :(

maraf avatar Jul 25 '25 12:07 maraf