Microsoft Official Document Address
Basic steps:
And then add to
Please refer to the top address for specific writing rules.
Small example:
1. Binding parameters
2. Select whether to display HTML content according to the parameters
3. Avoid tag helper conflicts
[Htmltargetelement ("P")] Public classautolinkerhttptaghelper:taghelper{ Public Override AsyncTask Processasync (taghelpercontext context, taghelperoutput output) {varChildcontent =awaitoutput. Getchildcontentasync (); //Find Urls in the content and replace them with their anchor tag equivalent.output. Content.sethtmlcontent (Regex.Replace (Childcontent.getcontent (),@"\b (?: https?:/ /) (\s+) \b", "<a target=\ "_blank\" href=\ "$0\" >$0</a>"));//http link Version} }}
In addition to a
[Htmltargetelement ("P")] Public classAutolinkerwwwtaghelper:taghelper { Public Override AsyncTask Processasync (taghelpercontext context, taghelperoutput output) {varChildcontent =awaitoutput. Getchildcontentasync (); //Find Urls in the content and replace them with their anchor tag equivalent.output. Content.sethtmlcontent (Regex.Replace (Childcontent.getcontent (),@"\b (www\.) (\s+) \b", "<a target=\ "_blank\" href=\ "http://$0\" >$0</a>"));//www version } }
You can turn the code into this
-----Tag Helper in. NET Core