.NET LinkTagHelper - how can I use it for CSS CDN files without explicit css class selectors?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



.NET LinkTagHelper - how can I use it for CSS CDN files without explicit css class selectors?



I have a .NET Core 2.1 app and in it I am pulling a few resources from CDN's via the "LinkTagHelper" .NET helper.



I started with an obvious example (that works just fine) like this:


<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
crossorigin="anonymous"
asp-fallback-href="~/lib/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only"
asp-fallback-test-property="position"
asp-fallback-test-value="absolute" />



Now that's all good, Fallback works (if needed) CSS "sr-only" class is tested for presence and correctness.



I am also trying to do the same thing for this CSS file on their CDN:


<link rel="stylesheet"
href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css"
integrity="sha384-EkHEUZ6lErauT712zSr0DZ2uuCmi3DoQj6ecNdHQXpMpFNGAQ48WjfXCE5n20W+R"
crossorigin="anonymous"
asp-fallback-href="~/lib/dist/css/dataTables.bootstrap4.min.css"
asp-fallback-test-class=".dataTable"
asp-fallback-test-property="clear"
asp-fallback-test-value="both" />



Now in that example above, the test css class, property and value options in place are wrong - they do not work, so the fallback is always loaded. I wonder if it's because in the dataTables css file (here is the un-minified version), there is no "class only" selector specified, they are all type + class.



So, I suspect that I can't do what I want here because I can't choose an appropriate CSS selector to use in the LinkTagHelper! If it's always going to fall back, then I may as well not have the CDN.



Am I using LinkTagHelper wrong, or otherwise not thinking about this properly?



(I know I can just always load it from my site and not bother with these shennanigans, but... if I'm doing CDN for one library, may as well be consistent).









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard