DEV Community


🧩 Using C# Extension Methods for Auth0 Authentication

robertinoc_dev profile image Robertino ・1 min read

C# extension methods let you easily add new functionality to existing classes. Learn how you can leverage them to simplify the Auth0 configuration for ASP.NET web apps.

ASP.NET Web Apps and Auth0

Adding Auth0 authentication to an ASP.NET web application is quite straightforward and doesn't require any specific Auth0 SDK. You can simply use the standard Microsoft.AspNetCore.Authentication.OpenIdConnect package to enable your web application to use the OpenID Connect (OIDC) protocol for user authentication. Let's take a look at how a typical ASP.NET web app configured with Auth0 looks like.

Getting the sample app

The sample application that comes with this article requires .NET Core 3.1 SDK, but you can easily adapt it to run with .NET 5 by simply changing the project's target framework.

As a first step, download the project from the starting-point branch of this GitHub repository. You can do it by running the following command in a terminal window:

git clone -b starting-point
Enter fullscreen mode Exit fullscreen mode

The project implements a basic ASP.NET MVC application that requires authentication to access the user's profile. It is the result of the Auth0 ASP.NET Core Quickstart.


Discussion (0)

Editor guide