liveBook · Manning

Asp-href-exclude

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

The asp-href-exclude attribute specifies a globbing pattern for stylesheet files to exclude.

asp-href-exclude specifies globbing patterns for stylesheet files that the built-in link tag helper must omit. Combine it with asp-href-include when a directory contains minified files, source maps, right-to-left variants, or feature subsets that should not become stylesheet links. section 26.4.2

Select only the intended Bootstrap stylesheet

<link asp-href-include="/lib/bootstrap/css/*.min.css" asp-href-exclude="**/*-reboot*,**/*-grid*,**/*-utilities*,**/*.rtl.*" rel="stylesheet" /> This configuration excludes Bootstrap reboot, grid, utilities, and right-to-left files. Inspecting /home/list in a browser should show one generated link for 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 asp-href-exclude with the related link tag helper attributes for inclusion, cache busting, and CDN fallback. section 26.4.2

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

How deep it goes
Explains glob exclusions through a Bootstrap layout example and rendered HTML inspection, without detailing globbing internals.
Examples
Uses Bootstrap minified files while excluding reboot, grid, utilities, and right-to-left variants.
What it assumes
Assumes familiarity with link elements, stylesheet files, ASP.NET Core layouts, and globbing-pattern syntax.
What you can do after
Operate/configure a link tag helper to emit only the desired local stylesheet files.
How it connects
Connects stylesheet selection with asp-href-include, CSS stylesheets, and CDN fallback attributes.

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.