I have ASP.NET Core 2.0 website, which is hosted in a .NET Core console / service. I have implemented a easy custom TagHelper. The TagHelper works fine, when I started the ASP.NET Core website directly from VS2017. When i start the .NET Core console host, which has hosted the asp.net page, the tag helper doesnt work.
I have try to register the TagHelper in the _ViewImports.cshtml and also directly in the view as self (Home/Index).
My custom TagHelper:
[HtmlTargetElement("time")]
public class TimeTagHelper : TagHelper
{
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
output.Content.SetHtmlContent($"<h1>{DateTime.Now.ToShortTimeString()}</h1>");
}
}
_ViewImports.cshtml
@using SelfHosted.Website
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper SelfHosted.Website.TagHelpers.*, SelfHosted.Website
The TimeTagHelper intellisense in VS2017 work fine: TimeTagHelper in Index.cshtml
The code is on GitHub. The TagHelper is implemented in SelfHosted.Website and used in /Home/Index. It works perfect when the SelfHosted.Website started directly. But it doesnt work, when i start the Website from SelfHostes.Console.
Ok ... I found the answer and documented here.
https://github.com/aspnet/Home/issues/2216#issuecomment-332751869