SQL Practice Blog – SQL Server, BizTalk und .NET Erfahrungen

Archive for the ‘Web Development’ Category

Self Hosted ASP.NET Core: TagHelper doesn’t work

leave a comment »

I have implemented a simple TagHelper in a ASP.NET Core 2.0 Website, which replace the

My custom TimeTagHelper:

public class TimeTagHelper : TagHelper
    public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)

If I start the website project directly, the TagHelper works without problems. Launched from the Console / Service, the

The solution: PreserveCompilationContext

These are the steps that helped me:

  1. Add the following ItemGroup definition to my Selhosted.Website.csproj
    <EmbeddedResource Include="wwwroot\**\*;Views\**\*;Areas\**\Views" />


  1. Add the PreserveCompilationContext property to the PropertyGroup in Selhosted.Website.csproj


  1. Include the generated SelfHosted.Website.deps.json from the websites bin folder to the SelfHosted.Console project and set the Copy to Output Directory to Copy always.64fcb891c62c3a149c6ff350ebe0b1d3

You can find the sample project in my GitHub Repo: roeb/DotNetCoreSamples


Written by Robert Meyer

September 29, 2017 at 07:56