question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tag Helpers not working in published site

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When running in the debugger, the “site.js” script tag successfully gets a hash appended to its query string (as expected), and the files matching the src-include have script tags generated for them. However, after publishing neither of these features work. It’s unclear if any other tag helpers are working either. Tested running both in IIS and just running the EXE file generated by the publish.

    <environment include="Development">
        <script src="~/Identity/lib/jquery/dist/jquery.js"></script>
        <script src="~/Identity/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
        <script src="~/Identity/js/site.js" asp-append-version="true"></script>
    </environment>
    <environment exclude="Development">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"
                asp-fallback-src="~/Identity/lib/jquery/dist/jquery.min.js"
                asp-fallback-test="window.jQuery"
                crossorigin="anonymous"
                integrity="sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2">
        </script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js"
                asp-fallback-src="~/Identity/lib/bootstrap/dist/js/bootstrap.bundle.min.js"
                asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
                crossorigin="anonymous"
                integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj">
        </script>
        <script src="~/Identity/js/site.js" asp-append-version="true"></script>
    </environment>
    <script type="module" asp-src-include="/js/header/polyfills.*.js"></script>
    <script type="module" asp-src-include="/js/header/main.*.js"></script>

Expected Behavior

Tag helpers, specifically src-include, work in a published app the same as in development.

Steps To Reproduce

  1. Create ASP Core Web API project with ASP Identity
  2. Override some Identity pages, including the main _Layout.cshtml. Leaving the existing markup is fine.
  3. Make sure the new Layout page is used by adding:
@{
    Layout = "/Pages/Shared/_Layout.cshtml";
}

To the _ViewStart.cshtml of the Identity area being overriden 4. (Optional) Add some script tags with asp-src-include

Exceptions (if any)

No response

.NET Version

6.0.203

Anything else?

.NET 6, VS 2022.

Also asked at https://stackoverflow.com/questions/73862284/asp-net-core-tag-helpers-dont-appear-to-be-working-in-published-exe#73862284

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
TanayParikhcommented, Oct 28, 2022
image

Confirmed, not seeing the version appended for the script tag, which should be there due to asp-append-version="true", in the published app.

Non-published app: image

0reactions
msftbot[bot]commented, Oct 4, 2022

Thanks for contacting us. We’re moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. Because it’s not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it’s very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio .Net Core tag helpers are not working
NET core tag helpers have completely stopped working, no idea why as I've not changed anything. I was in work one day, they...
Read more >
View component not being rendered using tag helper syntax
I am trying to use a view component using the tag helper syntax <vc:[view-component-name]> and since the latest .NET release (7.0.200) it is...
Read more >
How to fix Microsoft.AspNetCore.Mvc ... - SharePointProblems
The fix ended up being simple – just copypaste a suitable _ViewImports.cshtml under your /Views -folder. The _ViewImports.cshtml file is ...
Read more >
Tag Helpers in ASP.NET Core
There are many built-in Tag Helpers for common tasks - such as creating forms, links, loading assets and more - and even more...
Read more >
Tag helpers in Razor Pages
An introduction to tag helpers in ASP.NET Core Razor Pages, and how to build your own custom tag helpers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found