Difference between asp-fallback-test-property vs asp-fallback-test Difference between asp-fallback-test-property vs asp-fallback-test https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/script-tag-helper?view=aspnetcore-5.0 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/link-tag-helper?view=aspnetcore-5.0
asp-fallback-test-property
is specific to the link
tag-helper. It's the name of a CSS property you want to be interrogated, with asp-fallback-test-value
being the value you expect it to have (see the previous answer I wrote for the specifics).
asp-fallback-test
is specific to the script
tag-helper. It's just a JavaScript expression that will be evaluated - if it's truthy, no fallback will be used.
As an example of asp-fallback-test
, imagine the following script
tag:
<script src="/some/cdn/to/jquery"
asp-fallback-src="~/local/path/to/jquery"
asp-fallback-test="window.jQuery"></script>
In this example, after the browser attempts to load the script from /some/cdn/to/jquery
, the tag-helper will check whether window.jQuery
is truthy. If it is, there's nothing more to do. If it isn't (the CDN script couldn't be downloaded), it will inject a script
tag for ~/local/path/to/jquery
.
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/script-tag-helper?view=aspnetcore-5.0
Commonly used Script Tag Helper attributes
See Script Tag Helper for all the Script Tag Helper attributes, properties, and methods.
asp-fallback-test
The script method defined in the primary script to use for the fallback test. For more information, see FallbackTestExpression.
asp-fallback-src
The URL of a Script tag to fallback to in the case the primary one fails. For more information, see FallbackSrc.
https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/link-tag-helper?view=aspnetcore-5.0
href
Preferred address of the linked resource. The address is passed thought to the generated HTML in all cases.
asp-fallback-href
The URL of a CSS stylesheet to fallback to in the case the primary URL fails.
asp-fallback-test-class
The class name defined in the stylesheet to use for the fallback test. For more information, see FallbackTestClass.
asp-fallback-test-property
The CSS property name to use for the fallback test. For more information, see FallbackTestProperty.
asp-fallback-test-value
The CSS property value to use for the fallback test. For more information, see FallbackTestValue.