liveBook · Manning

Asp-fallback-test-class

As explained in Pro ASP.NET Core 7, Tenth Edition

The asp-fallback-test-class attribute specifies a CSS class whose presence is tested to determine whether a stylesheet loaded.

asp-fallback-test-class supplies the CSS class used to verify that a CDN stylesheet loaded. The class must be defined by that stylesheet; the built-in tag helper emits a test element and script that checks the configured CSS property before loading the fallback file. section 26.4.2

Testing Bootstrap

Set asp-fallback-test-class="btn" alongside asp-fallback-test-property="display" and asp-fallback-test-value="inline-block". Bootstrap's btn class supplies the expected property; if the CDN is unavailable, asp-fallback-href loads /lib/bootstrap/css/bootstrap.min.css. section 26.4.2

Table 26.6. The built-in tag helper attributes for link elements (view table figure)

Name

Description

asp-href-include

This attribute is used to select files for the href attribute of the output element.

asp-href-exclude

This attribute is used to exclude files from the href attribute of the output element.

asp-append-version

This attribute is used to enable cache busting, as described in the “Understanding Cache Busting” sidebar.

asp-fallback-href

This attribute is used to specify a fallback file if there is a problem with a CDN.

asp-fallback-href-include

This attribute is used to select files that will be used if there is a CDN problem.

asp-fallback-href-exclude

This attribute is used to exclude files from the set that will be used when there is a CDN problem.

asp-fallback-href-test-class

This attribute is used to specify the CSS class that will be used to test the CDN.

asp-fallback-href-test-property

This attribute is used to specify the CSS property that will be used to test the CDN.

asp-fallback-href-test-value

This attribute is used to specify the CSS value that will be used to test the CDN.

Compare this attribute with the related link tag helper attributes for selecting files, cache busting, and specifying fallback resources. section 26.4.2

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Explains generated meta and script output, CSS-property testing, and fallback loading, but not tag-helper internals.
Examples
Uses Bootstrap's btn class and its display: inline-block declaration to test a CDN stylesheet.
What it assumes
Assumes familiarity with CSS classes and properties while demonstrating the required fallback attributes from a layout.
What you can do after
Configure CDN stylesheet fallback with a class, property, expected value, and local fallback path.
How it connects
Connects ASP.NET Core tag helpers with CDN fallback files, CSS classes, CSS properties, and Bootstrap.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.