CDN fallback in ASP.NET Core application

21 Feb 20241 minute to read

This section provides information about how to refer fallback scripts and style sheet from CRG and Theme Studio when CDN is not available in ASP.NET Core application.

ASP.NET Core App

CDN links can be down by connection issues or some other problems. This will cause the site looks broken. Follow the below steps to resolve these issues in the ASP.NET Core application.

Style Sheet Fallback

If you are using CDN for style sheet references then you have to add style sheet fallback from Theme Studio by using the link tag helper. Syncfusion theme provides the e-control class. You can check the style from provided class by using link tag helper property inside the <head> of ~/Pages/Shared/_Layout.cshtml file as follows,

<head>
    ...
    <link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/25.1.35/bootstrap5.css"
    asp-fallback-href="~/styles/bootstrap5.css"
    asp-fallback-test-class="e-control"
    asp-fallback-test-property="font-size"
    asp-fallback-test-value="12px" />
</head>

Script Fallback

You can check the Syncfusion ASP.NET Core object for script fallback by using script tag helper and refer scripts externally from CRG inside the <head> of ~/Pages/Shared/_Layout.cshtml file in ASP.NET Core app as in the below code.

<head>
    ...
    <script src="https://cdn.syncfusion.com/ej2/25.1.35/dist/ej2.min.js"
    asp-fallback-src="~/scripts/ej2.min.js" asp-fallback-test="window.ejs"></script>
</head>