Follow @endyourif rss Facebook LinkedIn

HtmlHelper Extenstion to convert an object to JSON with C#

Published on Apr 10, 2019

Let's create an HTML Extension for C#'s HtmlHelper class that converts a class or object to JSON for use with your JavaScript code. I use this in my MVC projects inside my Razor Views. The solution leverages NewtonSoft's JsonConvert NuGet package.

C# HtmlExtension to display SVGs

Published on Feb 16, 2019

You have SVGs that you wish to display on your website but you want to be able to re-use them without copying and pasting the code or creating a shared view.

By creating an HtmlExtension class with a function called Svg you can create a centralized place to store and re-use your SVGs.