David HaydenDavid Hayden
  • Home
  • Blog
  • Contact
  • About

Orchard Core 1.0 Released!

I am pleased to announce that Orchard Core 1.0 is released! I've been developing Orchard Core websites, themes, and modules since 2018 using Orchard Core rc2, so I am especially excited to see Orchard Core being released as 1.0!

If you're new to Orchard Core and want to create a new Orchard Core Website, I have created an Orchard Core tutorial that walks you through installing the Orchard Core Code Generation Templates and using those templates to create a new Orchard Core website.

You can learn more about Orchard Core by exploring the Orchard Core Tutorials on my blog as well as visiting my Orchard Core Developer website.

Fix Docker VS Code Error: connect EACCES /var/run/docker.sock

After installing VS Code on Ubuntu 20.04 as well as the Docker VS Code extension, the VS Code extension displayed an error when it attempted to list the various Docker containers and images as well as connect to the Docker registry. The VS Code error displayed connect EACCES /var/run/docker.sock and questioned me if Docker was actually running. I've never received this error when using the Docker VS Code extension on Windows and macOS, so this was a new error message for me.

Turns out the error message is somewhat expected using Ubuntu (and Linux in general) when running Docker as a non-root user. There are a set of post-installation steps associated with managing Docker as a non-root user that need to happen. In my case I only had to do a couple of the steps and re-start the Virtual Machine to fix the error.

Install Azure Storage Explorer on Ubuntu 20.04 using Snap

As a Microsoft developer, I mainly use Azure for all my cloud services needs, whether this be for ASP.NET Core MVC, Web API, and Razor Pages development or Orchard Core development. Azure Storage is a critical piece of the Azure cloud services along with the Azure Web App Service and SQL Server Database services in most of my development projects. More complex projects will use Azure Functions, Azure API Management Services, and Cosmos DB services as well. In this tutorial I will quickly show how to install Azure Storage Explorer on Ubuntu 20.04 using Snap so Azure developers can quickly explore and manage their containers, file shares, tables, and queues in their storage accounts.

Configure NuGet.config in Ubuntu 20.04 for Orchard Core Preview Feed

Earlier I mentioned that I've been spending a lot of time using Ubuntu 20.04 in a virtual machine on my MacBook Pro. I've completely switched to Ubuntu when tutoring my computer science students in C, C++, Java, and Python, and use it more and more for .NET5 and C# 9 web application and web API development. Recently I wrote a quick tutorial on how to install .NET5 on Ubuntu 20.04 and now wish to show how to configure the global NuGet.config file in Ubuntu such that you can add additional package sources other than NuGet.org. In this tutorial, I will be adding the Orchard Core Preview feed to NuGet.config so that when I develop custom Orchard Core websites, modules, and themes using the pre-release version of Orchard Core, the pre-release packages used by Orchard Core will automatically be downloaded from the Orchard Core Preview NuGet feed.

Orchard Core .NET5 and C# 9

When .NET5 and C# 9 was released I eagerly began developing ASP.NET Core web applications and web API's using the new features. The C# 9 Record Types are especially handy as well as features in EF Core 5 like better handling of many-to-many relationships. As an Orchard Core developer I eagerly awaited for .NET5 and C# 9 support in Orchard Core as well. It took longer than I had hoped, but in the latest pre-releases of Orchard Core we can now develop Orchard Core websites using .NET5 and C# 9 as well as .NET Core 3.1. In fact by default, all new Orchard Core websites now target .NET5!

Assuming you've installed the latest pre-release version of the Orchard Core code generation tools, you can create an Orchard Core website using the .NET CLI with the following command...

Install .NET5 on Ubuntu 20.04

Although I have and continue to spend the majority of my time developing .NET5 ASP.NET Core web applications and web API's on macOS, I've noticed that I very much enjoy developing applications on Ubuntu.

Originally I installed Ubuntu on my MacBook Pro, because the majority of the computer science students I tutor also use Ubuntu. Being a huge fan of the JetBrains developer tools, I was excited that IntelliJ IDEA, CLion, and PyCharm ran just as well on Ubuntu as they do on macOS. And, of course, Visual Studio Code works wonderfully on Ubuntu, too. As most of my tutoring involves applications and code samples developed in C, C++, Java, and Python, this works out perfectly.

Wanting to spend even more time on Ubuntu, I have created Ubuntu virtual machines dedicated specifically for Microsoft development. I install .NET5, Visual Studio Code, and JetBrains Rider on Ubuntu for my C# development needs.

Orchard Core SEO Feature

In one of the recent pre-release versions of Orchard Core there is a new Orchard Core SEO feature to help Orchard Core developers and administrators manage meta tags commonly used by search engines and social media sites. The Orchard Core SEO feature does 3 things at this time. First, it helps one enter common and custom meta tags used by search engines to help index your Orchard Core website and position it favorably in search results. Second, it helps one enter common social media meta tags for Twitter and Open Graph to help market your brand when users share your Orchard Core website on social media. And last, the Orchard Core SEO feature also helps you enter Google structured data (Google schema) to help identify the type of data you're posting to your Orchard Core website and, once again, display it favorably in search engine results. If you have an Orchard Core website or are developing an Orchard Core website that you wish to optimize for search engines and popular social media sites, I recommend upgrading your Orchard Core website to the latest pre-release version of Orchard Core and enabling the Orchard Core SEO feature.

Update Orchard Core NuGet Packages

In addition to being a freelance Orchard Core developer, I am also an Orchard Core trainer. I teach developer teams how to develop, maintain, and deploy professional Orchard Core websites, themes, and modules. As such, I have developed 100's of custom Orchard Core samples to showcase Orchard Core development techniques and best practices. I use these samples as part of my Orchard Core training and it's important that they are up-to-date and demonstrate the latest techniques.

Since Orchard Core is still in preview and constantly being updated with bug fixes and new features, the Orchard Core NuGet packages used by these custom modules, themes, and websites are constantly becoming outdated. When I become aware of a new Orchard Core feature, bug fix, or best practice, I update the necessary samples, and part of this update includes updating any outdated NuGet packages.

Managing Orchard Core Secrets in Azure Key Vault

In the previous tutorial I talked about managing secrets for ASP.NET Core websites using the secret manager tool. User secrets and the secret manager tool are intended for use during development on your local PC. This keeps the developer from storing secrets in configuration files that may accidentally be exposed and/or pushed to a Git repository.

In the previous tutorial I also mentioned Microsoft's Azure Key Vault, which provides a secure way to safeguard cryptographic keys and other secrets used by your Azure resources. Since a large part of my development involves developing and deploying Orchard Core web applications to Azure cloud services, I use Key Vault quite often with Orchard Core for storing secrets. In this tutorial I will briefly discuss using Key Vault with Orchard Core, which you will realize is not much different than using Key Vault directly with ASP.NET Core Razor Pages and ASP.NET Core MVC.

ASP.NET Core User Secrets and Secret Manager Tool

When you're developing websites and web API's using ASP.NET Core, you often have passwords, API keys, and other secrets you wish to keep away from prying eyes. Adding these secrets to a configuration file, like appsettings.json, and accidentally pushing these to a Git repository could be disastrous. For development purposes, Microsoft provides a secret manager tool that stores sensitive data in a separate secrets.json file on your development PC that is read by the default configuration builder in ASP.NET Core. As such, you can avoid placing these secrets in your configuration files and accidentally adding them to your Git repository.

Generate Client for ASP.NET Core Web API using OpenAPI

Recently I talked about some of the new features in .NET 5.0 and preview versions of Visual Studio 16.8 and 16.9 with respect to ASP.NET Core Web API Projects. The first announcement I mentioned was the built-in support for OpenAPI and Swagger UI via Swashbuckle in the new ASP.NET Core 5 Web API Project Template, and the other announcement was a new feature introduced in Visual Studio 2019 that allows you to publish the web API to Azure API Management Services as part of the flow of publishing the ASP.NET Core Web API. Both of these tutorials mention Swashbuckle to generate the OpenAPI Specification Document. If you're generating an OpenAPI Specification Document for your ASP.NET Core Web API, you can use this same document to generate a client to consume your web API, which is what I will demonstrate in this ASP.NET Core Web API tutorial.

Recursive Fibonacci and Memoization in C#

The computer science students I tutor are learning memoization using the classic example of recursive Fibonacci. I remember learning these same topics during my data structures and algorithms courses. I also remember being very surprised at the performance before and after memoization.

Publish ASP.NET Core Web API to Azure API Management Services

In a previous ASP.NET Core Web API Tutorial, I mentioned how the new ASP.NET Core Web API Project Template for .NET 5 Framework includes the addition of Swashbuckle.AspNetCore to generate an OpenAPI Specification Document as well as a Swagger UI to explore and test the web API. This works in tandem with a new feature introduced in Visual Studio 2019 that allows you to publish the web API to Azure API Management Services as part of the flow of publishing the ASP.NET Core Web API. Of course, you have the option to opt-out of publishing to Azure API Management Services, and the ASP.NET Core Web API publish flow is smart enough to detect if you aren't using Swashbuckle to generate an OpenAPI Specification Document as well. In this tutorial, I am mainly showing the new OpenAPI feature that I talked about in much more depth in the previous tutorial mentioned above.

EF Core 5 Many-to-Many Relationships

If you're a Microsoft developer using EF Core, you are probably really excited about the new feature in EF Core 5 that makes creating many-to-many relationships super simple! Many-to-many relationships in EF Core 5 work intuitively now, so if you have installed the .NET 5 SDK or Visual Studio 2019 16.9 preview 1 you can test the new feature pretty quickly from a .NET Core Console Application targeting .NET 5. In this EF Core 5 tutorial, I will walk you through the standard sample application of building a many-to-many relationship between blog posts and tags in a SQLite database. I'll also be using the migrations feature in EF Core, because we'll be able to see from the initial migration that indeed the proper database tables are being created to support many-to-many relationships in EF Core 5. I'll also be using the new top-level programs feature in C# 9 to alleviate some of the boilerplate code and nesting of the code.

public class Post
{
    public int PostId { get; set; }

    [Required]
    [StringLength(50)]
    public string Title { get; set; }

    public ICollection<Tag> Tags { get; set; }
}

public class Tag
{
    public int TagId { get; set; }

    [Required]
    [StringLength(25)]
    public string Name { get; set; }

    public ICollection<Post> Posts { get; set; }
}

ASP.NET Core 5 Model Binding to C# 9 Record Types

ASP.NET Core 5 was just released and it includes a number of new features. Earlier I mentioned the built-in support for OpenAPI and Swagger UI via Swashbuckle in the new ASP.NET Core 5 Web API Project Template. Another new feature is improved model binding to support C# 9 record types.

The C# 9 record type is perfect for use as data transfer objects where immutability is valuable. Using them for view models in ASP.NET Core MVC and for transferring data back and forth from an ASP.NET Core Web API seem like good applications for record types.

[HttpPost]
public async Task<ActionResult<Contact>> Post([FromBody]NewContact newContact)
{
    var contact = _mapper.Map(newContact);

    _repository.Add(contact);
    await _repository.SaveChangesAsync();

    return CreatedAtAction("Get", new { id = contact.Id }, _mapper.Map(contact));
}

OpenAPI and Swagger UI in ASP.NET Core 5 Web API

Microsoft released ASP.NET Core 5. One of the new features mentioned in the ASP.NET Core 5 announcement is the "built-in" support for OpenAPI and Swagger UI in ASP.NET Core 5 Web API's. This isn't so much a new built-in feature as it is a change in the ASP.NET Core 5 Web API Project Template. Microsoft is simply including Swashbuckle as part of the template and configuring it with some default settings for your project.

Top-Level Programs in C# 9

Top-level programs in C# 9 remove the boilerplate and nesting in code, making it so much easier to share working sample C# code on my blog.

using System;

Console.WriteLine("Hello World!");

Guard Clauses in Computer Science

While assisting my computer science students on ways to help debug and improve the clarity and runtime of their code, I explained the concept of guard clauses. Guard clauses are true/false expressions (predicates) found at the top of a method or function that determine whether the function should continue to run. Guard clauses test for preconditions and either immediately return from the method or throw an exception, preventing the remaining body of code from executing.

C# 9 Record Type

The new record type in C# 9 is intended for immutability and has a number of cool features, including positional records, value-based equality, a useful ToString override, and support for the with-expression and init accessor.

record Person(string Name, int Age) { }

class Program
{
    static void Main(string[] args)
    {
        var person = new Person("John Doe", 18);

        Console.WriteLine($"Name: {person.Name}, Age: {person.Age}");
    }
}

// Output
Name: John Doe, Age: 18

C# 9 Init-Only Properties

C# 9 introduces init-only properties that allow you to set properties on a class that can only be set once during object initialization.

This is done using a new init accessor introduced in C# 9 as part of a class declaration.

public class Person
{
    public string Name { get; init; }
    public int Age { get; init; }
}

Orchard Core CMS Shortcodes and Shortcode Delegates

We talked about the new Shortcodes and Shortcode Templates Features in the previous Orchard Core CMS Tutorial. In this tutorial, let's create an Orchard Core CMS shortcode in code using a shortcode delegate: Orchard Core CMS Shortcodes and Shortcode Delegates. You can add these shortcodes as part of your custom Orchard Core CMS Theme or Module.

Orchard Core CMS Shortcodes and Shortcode Delegates

Shortcodes and Shortcode Templates in Orchard Core CMS

Orchard Core CMS supports shortcodes to make adding content to your Orchard Core CMS website easier! As an Orchard Core Developer it is possible to include shortcodes in custom modules and custom themes, but by far the easiest way to add shortcodes is via the Shortcode Templates feature. By enabling Shortcode Templates, one can create shortcodes in the backend with just a little knowledge of HTML and the liquid template language - no complex coding necessary.

I created an Orchard Core CMS tutorial that walks you through creating a Bootstap Alert shortcode using the Shortcode Templates feature. I also show you how to use the new shortcode to easily add a Bootstrap Alert to your website content: Shortcodes and Shortcode Templates in Orchard Core CMS. In future tutorials I will show you how to create shortcodes via a custom IShortcodeProvider to include as part of your custom module or custom theme. As an FYI, here is another tutorial on shortcode templates in Orchard Core CMS.

Shortcode Templates Feature Orchard Core CMS

Create Orchard Core CMS Website

Attended a local developer group meeting and was asked how to create an Orchard Core CMS Website. Turns out this is really easy whether you're an Orchard Core Developer or not. The Orchard Core Code Generation Templates that work with the .NET Core CLI make it really easy to create a website, Orchard Core Module, Orchard Core Theme, and even a modular .NET Core MVC Website. Here is a quick Orchard Core CMS Tutorial that shows you how to create an Orchard Core CMS Website.

Create Orchard Core CMS Website

Orchard Core Blog and Custom Recipes

I promised in an earlier Orchard Core CMS Tutorial that I would mention a feature in Orchard Core that allows developers to expose custom recipes in their Orchard Core CMS Themes and Modules and run them from the admin dashboard. Although a bit bare bones at the time of this tutorial, custom recipes are a very handy way for Orchard Core CMS Developers to add additional functionality and features to their custom themes and modules on the fly. I currently use custom recipes in my themes to add features like blogs, portfolios, product catalogs for e-commerce stores, FAQ's, etc. on demand. I also use custom recipes in my custom Orchard Core CMS Modules to help with special situations or monotonous tasks. Learn more about running custom recipes and setup recipes in Orchard Core CMS from the admin dashboard.

Running Custom Recipes in Orchard Core CMS from Admin Dashboard

Portfolio Widget - Orchard Core Theme Development

Developed a cool portfolio widget for one of my Orchard Core CMS Themes, and it got me thinking just how much I enjoy developing widgets, modules, themes, websites, modular .NET Core Apps, etc. with Orchard Core CMS. I am completely sold on Orchard Core and am thrilled to be an Orchard Core Developer. The liquid template language and the Templates Module are a real joy to use for creating shapes and views. I still enjoy Razor, but man, liquid is fun, and even cooler, I am able to and have developed custom liquid template language filters in Orchard Core to create new features and functionality! I'll be bundling the new portfolio widget as a custom recipe in my theme, which yeah... is a little tedious right now, but has some incredible advantages in terms of extensibility, separation of concerns, etc. So, I love creating those custom recipes, too, because they provide that extra BAM I love to give to my themes!

Orchard Core Development - Portfolio Widget

Taxonomies in Orchard Core CMS

Taxonomies Module was recently added to Orchard Core! Taxonomies allow you to categorize various content items in your Orchard Core CMS Website. I wrote a quick Orchard Core Tutorial that shows how to enable the Taxonomies feature, add a new Taxonomy Term Content Type, create a new Taxonomy, and attach the new Taxonomy Field to a Content Type. The tutorial categorizes movies by genres in a movie library.

Taxonomies in Orchard Core CMS

Recipe Migrations in Orchard Core CMS

I developed a custom Orchard Core CMS Module that creates a Bootstrap 4 Card Widget to test the new Recipe Migrations Feature. The new IRecipeMigrator Interface in Orchard Core can be used in place of IContentDefinitionManager in DataMigration Classes to execute recipe migration files. Having developed numerous setup recipes for custom Orchard Core CMS Themes (Coming Soon, Freelancer, Editorial, and more) as well as recipes that can be run from the Orchard Core Dashboard to add features on the fly, I much prefer using the new Recipe Migrations feature over IContentDefinitionManager when possible and appropriate.

Custom Orchard Core CMS Module Bootstrap 4 Card Widget

Using GraphQL via GraphiQL in Orchard Core CMS

GraphQL and GraphiQL were recently added to Orchard Core. A great way to get started with GraphQL in Orchard Core is to create a website using The Agency Theme and query the various BagParts and their repected Content Types, Parts, and Fields using the GraphQL Explorer (i.e. GraphiQL). In this Orchard Core CMS Tutorial I use GraphQL and GraphiQL to query the portfolio and its projects.

GraphiQL Intellisense in Orchard Core CMS

Develop a Custom Widget in Orchard Core CMS

If you're interested in Orchard Core CMS Development, you will enjoy this tutorial on developing a custom widget for Orchard Core CMS. From scratch, I show how to develop an Alert Widget using the Orchard Core admin and liquid templates. I create the Alert Widget Content Type, add a Text Field and HtmlBody Part, demonstrate how to set field settings for the Predefined List Editor (aka Options Editor), and develop the custom templates using Liquid with the support of the Template Module in Orchard Core CMS. If you're new to Orchard Core CMS, you should learn a few tips and tricks on Orchard Core Development.

Develop Custom Widget for Orchard Core CMS

Orchard Core CMS Theme Development

Let's continue working with The Blog Theme in Orchard Core CMS and add a new zone to the layout template for displaying shapes. We're not going to modify the original theme, however. Instead let's use the Templates Module in Orchard Core CMS to create a new Layout template that overrides the theme layout. If you're interested in becoming an Orchard Core CMS Developer, view the tutorial: Adding a New Zone to The Blog Theme Layout in Orchard Core CMS

Add Zone to The Blog Theme Layout in Orchard Core CMS

Templates in Orchard Core CMS

A new Orchard Core CMS tutorial showing how to override templates in The Blog Theme using the Templates Module. Let's enhance The Blog Theme by allowing authors to select a background image for articles using a Media Field and display the selected background image in a new liquid template that overrides The Blog Theme template. Developers interested in being Orchard CMS Theme Developers or extending the current themes in Orchard Core CMS will find this tutorial useful.

Liquid Templates in Orchard Core CMS

Available for Hire

I currently have some availability for a small Orchard Core website, custom module, or theme.

Contact Me

OrchardCore.io

I recently started a new website, OrchardCore.io, dedicated to tutorials and resources on Orchard Core. I added a new section for Orchard Core Developer Notes. The notes are bite-size tips and solutions to common Orchard Core challenges. Recent notes include: GraphQL Permissions in Orchard Core, OpenID Connect and Token Validation, the HTML Sanitizer in Orchard Core CMS, and enabling the new Code Mirror Editor for HTML Field and Text Field.

Visit OrchardCore.io
David Hayden

David Hayden is a freelance Microsoft developer in Sarasota, Florida specializing in Orchard Core CMS web applications and websites. David is also fluent in .NET Core, C#, ASP.NET Core MVC, Razor Pages, SQL Server, Web API, and Azure Cloud Services. David also mentors college students in computer science using C, C++, Java, and Python.

David is also a NASM certified Personal Trainer, Nutrition Coach, Corrective Exercise Specialiist, and Weight Loss Specialist. In addition, David is a Precision Nutrition Level 1 Coach and Optimize Level 1 Coach.

Discover OrchardCore.io

I recently started a new website, called OrchardCore.io, dedicated to Orchard Core tutorials and resources.

  • Orchard Core Search and Lucene Search Index
  • Orchard Core Theme - Resume
  • Orchard Core SEO and Media Slugify
  • Monaco editor in Orchard Core
  • Orchard Core .NET5 and C# 9
  • Orchard Core Admin Dashboard
Navigation
  • Home
  • Blog
  • Contact
  • About
  • Site Map
Copyright © 2021 David Hayden.