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.
@await Component.InvokeAsync(xxxx)
to render view component, Can it be rendered successfully after published? – PropeneComponent.InvokeAsync
does resolve the issue for me as well. – Rivet