0
votes

I've been trying to follow https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-2.1 to get tag helpers to work but no matter what I do they aren't recognised in intellisense, no breakpoints are hit in the code producing the html and the elements aren't transformed.

This is my EmailTagHelper.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.TagHelpers;

namespace eHealthy.TagHelpers
{
    public class EmailTagHelper : TagHelper
    {
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "a";    // Replaces <email> with <a> tag
        }
    }
}

This is my _ViewImports.cshtml

@using Microsoft.AspNetCore.Identity
@using eHealthy.Models
@using eHealthy.Models.AccountViewModels
@using eHealthy.Models.ManageViewModels
@using eHealthy.Helpers;
@using eHealthy.TagHelpers;


@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
@addTagHelper "*, eHealthy.TagHelpers"

This is the page where I try to invoke the helper

@model EditViewModel

@{
    ViewBag.Title = "title";
    Layout = "_Layout";
}

@*<h2>title</h2>*@

<form method="post">
    <email>
        potato
    </email>
</form>


<input type="hidden"/>
1

1 Answers

0
votes

Unquote your add of the tag helpers. Delete the eHealthy.TagHelpers helper, you do not need to even create it.

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers