Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
336 views
in Technique[技术] by (71.8m points)

asp.net core - addTagHelper in component document

So Im fairly new to Blazor and .Net Core and Im trying to include a custom TagHelper inside my MainLayout.razor like so:

@addTagHelper *, SmartBreadcrumbs

Inside the _Host file it works as expected, but in any other file Im getting:

The directives @addTagHelper, @removeTagHelper and @tagHelperPrefix are not valid in a component document. Use '@using ' directive instead.

Im not sure what Im missing in order to be able to use the tag inside other files then the _Host.cshtml.

Link to what Im implementing https://github.com/zHaytam/SmartBreadcrumbs

question from:https://stackoverflow.com/questions/65938115/addtaghelper-in-component-document

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't use Html tag Helpers in a Blazor app. There is no such thing.

Note: The _Host.cshtml file is a Razor Pages page, not a Razor Component page. Html tag Helpers can be used in Razor Pages App's pages. Thus you can use Html tag Helpers in the _Host.cshtml file. The component tag helper is used in the _Host.cshtml file to instantiate the Blazor SPA.

<component type="typeof(App)" render-mode="ServerPrerendered" />

Note: SmartBreadcrumbs is written for MVC and Razor Pages Apps, not Blazor. Search for SmartBreadcrumbs implemented with Blazor.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...