Skip to content
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

The ScriptTagHelper doesn't render the type attribute of the <script> tag when the target framework is .NET 9 #57664

Closed
1 task done
jsakamoto opened this issue Sep 2, 2024 · 2 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@jsakamoto
Copy link

jsakamoto commented Sep 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The ScriptTagHelper doesn't render the type attribute of the <script> tag when the target framework is the .NET 9. This problem will happen in both MVC Views and Razor Pages.

Expected Behavior

The ScriptTagHelper should render the type attribute of the <script> tag, as well as the .NET 8 is doing.

Steps To Reproduce

Step 1. Download and extract the zip file I attached below.

That zip file includes an ASPNET Core Razor Pages project that owns a default Razor Page (Index.cshtml) that includes the <script> tag with the type="module" attribute.

...
<body>
    <h1>Index</h1>
    <script type="module" src="~/index.js" asp-append-version="true"></script>
</body>
</html>

Step 2. Run that project with the following command in a terminal console.

dotnet run -f net9.0 --urls http://localhost:5000/

Step 3. Fetch the default document of that app with the following command in another terminal console.

curl http://localhost:5000/

Expected: I expected that I could see the output like the one below.

...
<body>
    <h1>Index</h1>
    <script type="module" src="/index.eeak79n6tu.js"></script>
</body>
</html>

Actual: I could not see the type attribute in the document the app rendered.

...
<body>
    <h1>Index</h1>
    <script src="/index.eeak79n6tu.js"></script>
</body>
</html>

Appendix

  • This problem won't happen when the target framework is .NET 8, not .NET 9. (You can verify that behavior with the command dotnet run -f net8.0 --urls http://localhost:5000/)

  • This problem also happens on MVC Views even if the target framework is .NET 9. (See also: 📦MvcApp1.zip)

Exceptions (if any)

There will be an error message in the web browser's developer console, like this:

Cannot use import statement outside a module.

.NET Version

9.0.100-preview.7.24407.12

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 2, 2024
@martincostello
Copy link
Member

Duplicate of #57138.

This is already fixed for RC.1: #57170

@jsakamoto
Copy link
Author

Oh, I'm sorry for that I couldn't see that this was a duplicate of #57138 at that time. Anyway, I'm happy to hear that this problem will be fixed in RC1. Thanks, team, for your great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants