Roundup #9: Razor Email Templates, AWS Lamba .NET Core 2.1, Contract First API Design with OpenAPI V3

Here are the things that caught my eye this week.  I’d love to hear what you found most interesting this week.  Let me know in the comments or on Twitter.

Walkthrough: Creating an HTML Email Template with Razor and Razor Class Libraries and Rendering it from a .NET Standard Class Library

HTML emails are the absolute worst.  Inlined styles.  Nested tables.  Different apps and platforms render the markup differently.  It’s an absolute train wreck.  However, sending plain text emails isn’t a great way to impress your users and often makes emails look fake or like spam.  So fine, HTML emails.  Let’s do it.

Link: https://scottsauber.com/2018/07/07/walkthrough-creating-an-html-email-template-with-razor-and-razor-class-libraries-and-rendering-it-from-a-net-standard-class-library/

 

AWS Lambda Supports .NET Core 2.1

You can now develop your AWS Lambda function code in C# using the .NET Core 2.1 runtime which will soon be the Long Term Support (LTS) version of .NET Core.

Link: https://aws.amazon.com/about-aws/whats-new/2018/06/lambda-supports-dotnetcore-twopointone/

 

Contract First API Design with OpenAPI V3 – Darrel Miller

The Swagger specification is all grown up with it’s new enterprisey name, OpenAPI and there’s a whole set of new features in V3, like links and callbacks. This session will explore what’s new in OpenAPI V3 while designing and building an HTTP API.

Most Swagger/OpenAPI users started by generating their OpenAPI from an API implementation. As developers gain experience, many start to change their approach to start with an OpenAPI description and build an implementation from that. We will compare the approaches and talk about the advantages of Contract First with OpenAPI.

Link: https://www.youtube.com/watch?v=GtTiIY51kK0

 

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Using Razor in a Console Application (outside of ASP.NET Core MVC)

Razor in a Console ApplicationIn addition up to my previous post, Using ASP.NET Core Razor Views from a Class Library,  I wanted to also dig into how you can use Razor in a Console Application.  Basically from outside of ASP.NET Core MVC.

The most likely situation for this is wanting to generate Emails using Razor that are being sent from a service or console application.  The other might be from another web framework/middleware inside of ASP.NET Core.

To demo how to use Razor outside of ASP.NET CORE MVC, I’m going to use Razor in a Console Application.  Specifically I’m using netcoreapp2.1 for this demo but you can use anything netstandard2.0.

If you’re looking at rendering Razor views from ASP.NET Core MVC for the purpose of generating email content, I recommend checking out Scott Sauber’s blog post: Walkthrough: Creating an HTML Email Template with Razor and Razor Class Libraries and Rendering it from a .NET Standard Class Library.

RazorViewStringRenderer

The heart of the code is actually from RazorViewToStringRenderer.cs in the aspnet/Entropy repo on GitHub.  This repo is for:

A chaotic experimental playground for new features and ideas – check here for small and simple samples for individual features.

NuGet Packages

In our Console App, you’ll need the following packages:

<PackageReference Include=”Microsoft.AspNetCore.Hosting” Version=”2.1.1″ />
<PackageReference Include=”Microsoft.Extensions.FileProviders.Physical” Version=”2.1.1″ />
<PackageReference Include=”Microsoft.Extensions.PlatformAbstractions” Version=”1.1.0″ />

Instantiating

In order to generate a new instance of the RazorViewToStringRenderer class, the simpliest way I’ve found is to create a ServiceCollection and AddMvc() along with a few others.

If you plan on taking this code, you might want to only generate a single instance and reuse it through your application as generating it is fairly costly.

Emails

As mentioned with using Razor for emails, I highly recommend checking out Scott Sauber’s blog post: Walkthrough: Creating an HTML Email Template with Razor and Razor Class Libraries and Rendering it from a .NET Standard Class Library.  It has everything you need to get setup using Razor to generate emails when using ASP.NET Core MVC.

Source

All of the source code for this sample is up in my AspNetCore.Razor.ClassLibrary.Demo repo on GitHub.

If you have any comments or suggestions, please let me know in the comments or on Twitter.

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Roundup #8

Here are the things that caught my eye this week.  I’d love to hear what you found most interesting this week.  Let me know in the comments or on Twitter.

ASP.NET Core 2.2 Roadmap

We are currently planning to have 3 previews before RTM:

  • August – Preview 1
  • September – Preview 2
  • October – Preview 3
  • Before End-of-year – RTM

As with our previous roadmap posts this is what we intend right now, but it’s subject to change as we continue development.

Link: https://github.com/aspnet/Announcements/issues/307

 

Windows Command-Line: The Evolution of the Windows Command-Line

Welcome to the second post in this “Windows Command-Line” series. In this post we’ll discuss some of the background & history behind the Windows Command-Line. Specifically, we’ll explore its humble origins in MS-DOS, to its modern-day incarnation supporting tools like PowerShell and Windows Subsystem for Linux.

Link: https://blogs.msdn.microsoft.com/commandline/2018/06/27/windows-command-line-the-evolution-of-the-windows-command-line/

 

Analyzing .NET Core project dependencies: Finding transitive dependencies

In the previous blog post, I looked at how we can use the .NET Core CLI to generate a dependency graph which allows you to determine the package references for a .NET Core or .NET Standard project. This is the same technique I used when developing dotnet-outdated.

Once dotnet-outdated started gaining a bit of traction, one of the issues opened on the GitHub repository was a request to support detecting outdated transitive dependencies.

Link: https://www.jerriepelser.com/blog/analyze-dotnet-project-dependencies-part-2/

 

The Web That Never Was – Dylan Beattie

The story of the web is a story about freedom. It’s a story about information, about breaking down barriers, about creating new ways for people to communicate, to collaborate, and to share their ideas. It’s also a story that has as much do with marketing, money and meetings as it does with research and innovation. It’s a story of mediocre ideas that succeeded where brilliant ideas failed, a story of compromises, rushed deadlines and last-minute decisions. And it could so easily have been very, very different.

What if IBM had hired Digital Research instead of Microsoft to develop the operating system for their first PC, way back in 1980? What if Marc Andreessen and Jim Clark had gone to work for Nintendo in 1993 and never founded Netscape? What if one of the team at CERN had said “Tim, won’t it sound a bit silly if everyone spends the next fifty years saying double-you-double-you-double-you all the time”?

In this talk, Dylan Beattie will explore alternative history of the world wide web – a web with no Microsoft, no Windows; no Firefox, no Google and no JavaScript. A software industry from another timeline, a world of platforms, protocols and programming languages that are unmistakably alien – and yet strangely familiar.

Link: https://www.youtube.com/watch?v=j51Fmn4JVwU

 

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.