Hi, I'm Nate. I'm a developer and a Microsoft MVP who writes about .NET, JavaScript, APIs, and more.

Want more goodness? Enter your email and I'll send you new posts every week.

Introducing the OpenID Connect debugger

The OAuth 2.0 and OpenID Connect protocols are used all over the web. Big platforms like Google and Facebook use them extensively for both authorization and social login (the ubiquitous Facebook Login button). These protocols are powerful, but unfortunately they aren’t always easy to use.

If you’ve ever struggled to set up OAuth or OpenID Connect, you’re not alone! I got so tired of fighting with bad requests and cryptic responses that I decided to write a tool to make it easier.

A little book update

It’s been over two months since I released the Little ASP.NET Core Book, and I’ve been blown away by the response!

“This looks great. I’ve been learning ASP.NET Core with scattered resources around the web, and your book seems to explain everything in a simple way.” - aesthetics1 on HackerNews

I’ve been excited to see people downloading and tweeting about the book, but I’m even more excited to see people forking the content, adding suggestions, and translating it to other languages.

Set up the ultimate Windows 10 console

The console (terminal) on Windows has come a long way since command.com. PowerShell might seem weird at first if you’re used to bash on *nix, but it’s grown into a very powerful console and scripting tool.

Over the years, I’ve gathered a list of my favorite plugins and tweaks to make PowerShell and the console even better. In this post, I’ll show you how to customize PowerShell on Windows 10 for an awesome console experience.

Async/await in a console application

I’m a big fan of the async/await pattern introduced in C#. It’s one of the best ways to reason about asynchronous code, and it’s spreading to Python and JavaScript too.

Every once in a while, I need to run some async code in a .NET command-line application, but the Console Application template in Visual Studio makes it annoyingly difficult to do.

Serialize all errors as JSON in ASP.NET Core

A web API that returns JSON responses should be expected to return errors or exceptions as JSON messages, too. You can use exception filters in ASP.NET Core MVC to trap and serialize exceptions that occur within MVC. However, if an exception is thrown before (or after) the MVC pipeline, it won’t be handled by the filter and the client will get an ugly error message (or a 500 Internal Server Error).

A more universal solution that can trap and serialize any exception that happens during a request is an exception handling middleware component. The syntax is a little different than an exception filter, but the principle is the same.

In this post, I’ll show you how to write error handling middleware and how to extend it with custom behavior.

Modeling beautiful JSON APIs with Ion

JSON is by far the most popular response format for APIs today. It’s not hard to see why: it’s easy for both humans and machines to read. Virtually all platforms and devices can read and write JSON, making it nearly as ubiquitous as HTML. JSON is unstructured and “squishy”, which makes it easy to model dynamic responses. (Maybe a little too easy.)

If you’re building an API, especially one with more than a few endpoints, you’ll likely want to adopt a schema or pattern for your responses. This could be as simple as one or two common response properties, or it could be a complex message envelope. Unlike XML, JSON doesn’t have a built-in way of defining a document schema (the downside of being unstructured and squishy).

There are a few popular ways to add schemas to JSON, but they all have drawbacks. In this post, I’ll examine some of those drawbacks, and show you how to use Ion to create intuitive, beautiful REST APIs.

What is HATEOAS?

HATEOAS, or Hypermedia as the Engine of Application State, is a complicated-sounding term for a simple idea:

A client interacts with a REST API entirely through the responses provided dynamically by the server.

Put even more simply:

You shouldn’t need any documentation or out-of-band information to use a REST API.

This may sound odd, because the first stop for any developer working with a new API is the documentation. How could you interact with an unfamiliar API without any out-of-band information?

Close Notepad with Control-W

I use Atom and Notepad++ for most text editing tasks on Windows, but occasionally I’ll drop down to good, trusty Notepad. It loads fast and handles bare-bones editing tasks without much fuss. However, I found it annoying that there was no shortcut to quit Notepad other than Alt-F4, which feels awkward on my keyboard. Why can’t I use Ctrl-W?

Asynchronous uppercase at scale

shoutcloud.io is a hilarious parody of software-as-a-service offerings that provides All Caps as a Service. If you aren’t happy with the uppercasing function built into your language of choice, you can make an (absolutely spurious) HTTP request to API.SHOUTCLOUD.IO/V1/SHOUT and get back a shoutier version of any string.

Shoutcloud proudly states that they have libraries for “leading webscale platforms” like Node, Ruby, and Go. Sadly, they seem to have left out the .NET stack. What’s a responsible .NET developer to do?

Copyright © 2018. Created with love by Nate Barbettini.