Last week I was doing a little experiment for our Auth0 support for ASP.NET Core which involved writing a Tag Helper. For this Tag Helper I had to access the actual URL for the request, so I therefore had to somehow get a hold of the HttpRequest inside of the Tag Helper. Injecting IHttpContextAccessor The Request is not available as a property of the TagHelper base class so I figured that I needed to inject IHttpContextAccessor into my Tag Helper’s constructor, for example:
Introduction In a previous blog post I demonstrated the support for option groups in the new Select TagHelper in MVC 6. Someone asked about using enums with the Select TagHelper, so let us look at how you can use enums with the TagHelper. This blog post is based on ASP.NET 5 Beta 7. Basic binding For demonstration purposes, let us assume that we have an enum type with the list of possible relationship types:
Introduction In MVC 6 we are switching away from the use of the classical HTML Helpers in our Razor views to use TagHelpers instead. Various posts have been written about the new TagHelpers in MVC 6. If you are not familiar with them, then a good place to start would be Dave Paquette’s Complete Guide to the MVC 6 Tag Helpers or Matthew Jones’ Tag Helpers in ASP.NET 5 - An Overview.