Skip to content

Static files and Blazor start script section with CDN Url as parameter #34774

@mariovh-fnet

Description

@mariovh-fnet

[EDIT by guardrex to fix the code formatting. @mariovh87 ... FYI ... it's triple-backticks above and below for code blocks in issue comments.]

Description

In a WebApp project, I need the static files in App.razor, including the Blazor startup section:

<link href="main.css" rel="stylesheet"/>
<script src="_framework/blazor.web.js" autostart="false"></script>
<script>
  Blazor.start({
    webAssembly: {
      loadBootResource: function (type, name, defaultUri, integrity) {
        console.log(`Loading: '${type}', '${name}', '${defaultUri}', '${integrity}'`);
        switch (type) {
          case 'dotnetjs':
          case 'dotnetwasm':
          case 'timezonedata':
          case 'assembly':
             return `https://EP-custom-cdn.azurefd.net/_framework/${name}`;  
        }
      }
    }
  });
</script>

I want the CDN URL to be configurable via an environment variable in appsettings.json for production purposes.

How can this be done?

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/static-files?view=aspnetcore-9.0&source=docs#deliver-assets-with-map-static-assets-routing-endpoint-conventions

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/fundamentals/static-files.md

Document ID

25458428-030f-6acb-457e-1b4dfa722043

Article author

@guardrex

Metadata

  • ID: b0af7f84-f8dd-92d9-dacd-2aab76d3a039
  • PlatformId: 88af5647-85fa-eaf4-cbe1-4d0d4fdf521b
  • Service: aspnet-core
  • Sub-service: blazor

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions