I am going to deal with ASPNET CORE [version 1.1 using VS2017 Community, version 15.1 (26403.3)] I created a working ViewComponent called UserDetails
(abbreviated below):
namespace AdminConsole.ViewComponents
{
[ViewComponent(Name = "UserDetails")]
public class UserDetailsViewComponent : ViewComponent
{ ...does stuff... }
and I can successfully call it in the view using
@await Component.InvokeAsync("UserDetails")
I would prefer to reference it using TagHelper, but that just doesn't happen. I went through SO and other useful pages, and others seem to make it work, I can't.
I added a line @addTagHelper "*, AdminConsole"
in _ViewImports.cshtml and <vc:user-details></vc:user-details>
in the view in which I want to display the VC, and it does not; I do not get the error, it just does not display.
If I changed the TagHelper declaration to @addTagHelper *, AdminConsole
(without voice tags), it will also not be displayed or will not be an error.
, , <vc:UserDetails></vc:UserDetails>
.. , .
_ViewImports.cshtml
@using AdminConsole
@using AdminConsole.Models
@using AdminConsole.Models.AccountViewModels
@using AdminConsole.Models.ManageViewModels
@using Microsoft.AspNetCore.Identity
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@inject Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration TelemetryConfiguration
@addTagHelper "*, AdminConsole"
VC @addTagHelper
(AdminConsole.ViewComponents
) cannot resolve TagHelper
.
, , , ( !). , - .