Skip to content

Instantly share code, notes, and snippets.

View is-consulting's full-sized avatar
🎯
Focusing

Ian is-consulting

🎯
Focusing
View GitHub Profile
@is-consulting
is-consulting / ActiveRouteTagHelper.cs
Created March 17, 2018 21:11
Asp.net Core 2.0 TagHelper for adding 'active' class to current active link. Compatible to lowercase routing, LowercaseUrls
[HtmlTargetElement(Attributes = ControllersAttributeName)]
[HtmlTargetElement(Attributes = ActionsAttributeName)]
[HtmlTargetElement(Attributes = RouteAttributeName)]
[HtmlTargetElement(Attributes = ClassAttributeName)]
public class ActiveRouteTagHelper : TagHelper
{
private const string ActionsAttributeName = "asp-active-actions";
private const string ControllersAttributeName = "asp-active-controllers";
private const string ClassAttributeName = "asp-active-class";
private const string RouteAttributeName = "asp-active-route";