Override for Razor Class Library does not work with current partial tag helpers
See original GitHub issueWe use the latest <partial name="" />
tag helper, but somehow it does not work when you override it in the actual MVC project, so the browser renders exactly the tag which means Razor does not recognise it as a valid partial wrapper.
One of the solutions could be to rollback to the old implementation of rendering partials, like @await Html.PartialAsync("_partial.cshtml")
Or we can completely get rid of the partials and start using components instead (https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-components?view=aspnetcore-2.2). I like this option more, but needs to be tested if Razor engine on the top project can recognise it.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Class Library Tag Helper for Partial Pages not working in ...
In the ASP.NET Core 3.1 Razor Page, the custom Tag Helper code requires a 'using' reference to the Microsoft.AspNetCore.Mvc.ViewFeatures.Buffers ...
Read more >Tag Helpers in ASP.NET Core
Learn what Tag Helpers are and how to use them in ASP.NET Core.
Read more >Partial Tag Helper in ASP.NET Core
The Partial Tag Helper is used for rendering a partial view in Razor Pages and MVC apps. Consider that it: Requires ASP.
Read more >Working with Razor Class Libraries in ASP.NET Core
Overriding Class Library Content The consuming application can override any aspect of the Razor Class Library by emulating the area folder ...
Read more >The Anchor Tag Helper in Razor Pages
The anchor tag helper targets the HTML anchor ( <a> ) tag which is used to generate relative links from the values passed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So I have experimented more with this, and if we would convert to use Razor Pages instead of Controllers, we would make it possible to override our pages from many more folders.
Using a structure like this:
We can then allow users to override our partials in these places whether or not the calling application is made with Razor Pages or Controllers.:
By staying with Controllers, I could only override the partials in 2 places, which I think it was these two
Opened a new issue for further discussion regarding conversion. Here we simply update the documentation so it describes how to override partials.