On a Net Core 7 project I am rendering a View Component on a Razor page:
<vc:footer></vc:footer>
The component C# code is:
public class FooterViewComponent : ViewComponent {
public FooterViewComponent() { }
public IViewComponentResult Invoke() {
return View("Footer");
}
}
And the HTML, in file /Pages/Shared/Components/Footer/Footer.cshtml is:
<footer>My Footer Test</footer>
When I run the application in my computer the footer is rendered.
But when I publish to the server, in production, the footer view component is not rendered.
When inspect the code of the page in the browser and it shows:
<vc:footer></vc:footer>
Any idea why? I really have no idea why this happens.
This is a known bug and can be tracked with this GitHub issue.
From what I understand this is an issue on Linux servers, so if you are developing on a Windows machine this could be the difference that you are experiencing. I am developing on a Mac and it breaks locally as well as on the Linux server I deploy to.
Workaround
The current workaround is to use
global.jsonto pin to an earlier working version. I was using SDK version 7.0.201 and it was breaking. However using the previous version 7.0.104 fixes the issue for me locally (Mac) and in production (Linux).global.json