-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Razor regression in ASP .NET Core 9.0 (script type=importmap and others) #58973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I would like to upgrade to 9.0, however this is hitting me on a asp.net core mvc project upgrading from net8.0. Any suggestions for how to get it to render correctly would be greatly appreciated. I concur that it should not override anything but render it as written. |
I currently use the following workaround for tag helpers that definitely should not be processed on a server side: <!script type="importmap">...</!script>
However, I'm still sure that tag helper should not remove a tag if it cannot process it on a server side. |
Thanks Alexanderm, that’s a nice addition to know. I hadn’t come across that before. However, this should be fixed as it is an unexpected condition. At the very least, the documentation for importmap should indicate this as a temporary workaround until they are able to fix it.
Thanks for the pointer.
From: Alexander Bessonov ***@***.***>
Sent: Thursday, November 21, 2024 4:20 AM
To: dotnet/aspnetcore ***@***.***>
Cc: Andre Hazelwood ***@***.***>; Comment ***@***.***>
Subject: Re: [dotnet/aspnetcore] Razor regression in ASP .NET Core 9.0 (Issue #58973)
I currently use the following workaround for tag helpers that definitely should not be processed on a server side:
<!script type="importmap">...</!script>
<!tag> syntax is an official way to turn off tag helper processing.
However, I'm still sure that tag helper should not remove a tag if it cannot process it on a server side.
—
Reply to this email directly, view it on GitHub<#58973 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACS73GFMU2IM5ND3H5IIV32BWQTLAVCNFSM6AAAAABR2WEKWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJQGQ3TQMBYHE>.
You are receiving this because you commented.Message ID: ***@***.******@***.***>>
|
BTW, I suggest using this workaround for all "non-default" usages of We, for example also had to implement a workaround for |
This one caught me as well, a bit sweaty when my importmap (part of _Layout.cshtml) wasn't rendered, considering the relatively good feeling I had combining razor views with ES6 modules. Fortunately the work-around with the |
I just spent a lot of time trying to figure out why my perfectly valid It turned out the import map wasn't showing up in my HTML response from ASPNET Core... When I add the |
Here's the cause of the issue public override void Process(TagHelperContext context, TagHelperOutput output)
{
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(output);
if (string.Equals(Type, "importmap", StringComparison.OrdinalIgnoreCase))
{
// This is an importmap script, we'll write out the import map and
// stop processing.
var importMap = ImportMap ?? ViewContext.HttpContext.GetEndpoint()?.Metadata.GetMetadata<ImportMapDefinition>();
if (importMap == null)
{
// No importmap found, nothing to do.
output.SuppressOutput();
return;
}
// ...
}
// ...
} Because the Additionally, if you aren't using the import map feature that's part of Razor components then ASP.NET Core assumes the Hey, guess what ASP.NET Core... you don't get to decide if valid HTML is rendered or not 😠. It looks like the regression was added in this PR #56045 |
Nice chase-down @seangwright. This is definitely a big with the .NET 9 framework. Team please resolve this. We are NOT using the new static asset pipeline and the behaviour of the rendering of our website should not change by upgrading – this is an unintentional regression. |
The worst part about this bug is that this post doesn't come up as a solution when you Google it. A stackoverflow post comes up about using the new |
@AlexBAV could you change the title of this issue to mention "importmap"? It might make it easier for others to find. |
Is it better now? I've also modified a top-level post with a link to the workaround. |
Is there an existing issue for this?
Describe the bug
The following razor snippet renders to nothing (is completely ignored??) in ASP.NET Core 9.0. Used to work correctly in previous version:
Looks like a bug in server-side script tag helper.
IMPORTANT! Suggested Workaround:
See below for a suggested workaround.
Expected Behavior
Should render "as is", without modifications
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
9.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: