Posts

Showing posts from 2016

Inline Image TagHelper

Finally getting my head around APS.NET 5.0 core. One of the features I really like are the Razor TagHelpers -- which are kinda like Angular Directives for the Server. I was reading a post by Ricardo Peres on his blog, Development With a Dot  called Inline Images in ASP.NET MVC core which details how to create an HtmlHelper to inline images. Basically, inlining an image is just converting a graphic file to a Base64 encoded string and using that as the src rather than a relative or absolute URI. <img src="data:image/png;base64,iVBORw0K...AAAAASUVORK5CYII="/> You see this sometimes in stylesheets if you want to specify a background image inline. background-image: url('data:image/png;base64,iVBORw0K...AAAAElFTkSuQmCC'); It's really useful if you want to embed a graphic in the stylesheet without having to include an external file. For web pages, it's not quite as useful. You cut down on the number of file requests, but increase the size of your HT