.netgithub-actionsrenderingtag-helpers

View Component not rendering when deployed - Works locally


We recently moved to GitHub actions for deployments and I am unsure if this is related to the issue or not. The component works when run locally and when published from Visual Studio but not via GitHub.

We have the following in the _Layout.cshtml page: <vc:header is-error-page="false"></vc:header>

And this in the _ViewImports.cshtml page:

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Project.Common.Web
@addTagHelper *, Project.Admin.Web

And the the component InvokeAsync:

public class HeaderViewComponent : ViewComponent
{
    private readonly IMediator _mediator;

    public HeaderViewComponent(IMediator mediator)
    {
        _mediator = mediator;
    }

    public async Task<IViewComponentResult> InvokeAsync(bool isErrorPage)
    {
        var model = await _mediator.Send(new Header.Query(UserClaimsPrincipal, HttpContext.Session.GetString(SessionKeys.HeaderRole)!, isErrorPage), HttpContext.RequestAborted);

        return View(model);
    }
}

One interesting thing is if you view the page source after it is deployed it is rendered correctly with all the html. But in the dev tools it is not it just shows up like it is in the code: <vc:header is-error-page="false"></vc:header>

Also no changes were made to this portion of the code or associated dependencies. The js and css seem to be included as usual as well.

Any help would be appreciated.

Also: https://stackoverflow.com/questions/44078195/view-component-as-a-tag-helper-does-not-get-invoked looks to be an identical issue but the answer isn't helpful.

Outside of just rebuilding and redeploying there hasn't been much we can think of to do. The issue just started happening and we were able to deploy via GitHub actions successfully before.


Solution

  • This appeared to be caused by the latest .net SDK using a preview build version. We were able to get around it by adding a globals.json file in the root or our project and specifying a version that wasn't broken.

    {
      "sdk": {
        "version": "7.0.102"
      }
    }