WebEssentials.AspNetCore.CdnTagHelpers
WebEssentials.AspNetCore.CdnTagHelpers copied to clipboard
StyleTagHelper results in empty <style> tags
Steps to reproduce:
- Create new ASP.NET Core web app
- Add NuGet reference to CdnTagHelpers 1.0.16
- Add
@addTagHelper *, WebEssentials.AspNetCore.CdnTagHelpersto _ViewImports.cshtml - Make appsettings.json change as recommended in README
- Add the
styletag below to Index.cshtml - Run app, view source. Note that the style tag renders as
<style></style>and the rule(s) have been removed. - Add
@removeTagHelper WebEssentials.AspNetCore.CdnTagHelpers.StyleTagHelper, WebEssentials.AspNetCore.CdnTagHelpersto _ViewImports.cshtml - Refresh page, note that styles return
Add to Index.cshtml:
<style>
.foo {
color: blue;
}
</style>
appsettings.json:
{
"cdn": {
"url": "https://myname.azureedge.net"
}
}
Rendered source with StyleTagHelper enabled:
<style></style>
Just experienced the same problem of inline styles getting removed. Any available workaround on this?
You can skip the Style Helper altogether. Update the _ViewImports.cshtml page with the following:
@addTagHelper WebEssentials.AspNetCore.CdnTagHelpers.CdnTagHelper, WebEssentials.AspNetCore.CdnTagHelpers
@addTagHelper WebEssentials.AspNetCore.CdnTagHelpers.PreConnectTagHelper, WebEssentials.AspNetCore.CdnTagHelpers