
In this writeup, I’ll demonstrate how to use Azure AD B2C to delegate identity and access management to Azure. One of the key difference is that we will not pre-register users in Azure AD using Azure AD domain name, like previous post, instead consumers of our applications can create users using any domain e.g. gmail.com.

In this and the next post I’ll demonstrate how to use Azure AD to delegate identity and access management to Azure, simplifying our application.

As developers we learn that giving meaningful names to methods produces clean, readable and maintainable code. However, that’s not all we should be concerned about when it comes to method signatures. There are two other aspects of a method signature that must be given consideration when writing code: a) parameters b) return value.

An enum is a special value type that lets you specify a group of named numeric constants. They can help make code more readable, as opposed to using int to represent constants or flags.

In a previous post, I showed how to use cookie authentication middleware to protect your web application. ASP.NET Core also provides a richer set of services, called Identity, to work with user authentication and management scenarios. For instance, in addition to authentication and password hashing, it provides features for registering new users, creating forgot & reset password tokens and their validation, two-factor authentication and authentication using external providers.

Please read the previous posts before continuing with this one. I have discussed the basics of Docker and shown how to deploy simple and multiple applications using Docker. In this post, I will use the code from the first post and demonstrate the continuous integration with TeamCity.
Deploy ASP.NET Core services to a Docker Swarm cluster in Azure using Docker EE for Azure, SSH tunneling, and Docker stack deployment.
Set up a Docker Swarm cluster with Docker Machine and deploy an ASP.NET Core application stack using Docker Compose, services, and replicas.

Deploy an ASP.NET Core Web app and API as separate Docker containers using Docker Compose, Docker Hub, and Azure Web App for Containers.

Now that you have a registry and key to upload your packages, let’s create and push a package. I am using here a simple .NET Core class library I wrote to work with CSV files, the source code can be found on GitHub. You can of course use any of your projects.

Azure provides a highly scalable, configurable and easy to use Platform-as-a-Service (PaaS) environment for our ASP.NET Core web applications. Azure Web App is one of the simplest ways to host web applications and the new Web App Container makes it really easy to host Docker containers.

In an earlier post I discussed how to prevent insecure object references by encrypting the internal references (e.g. table primary keys) using Data Protection API. To avoid duplication of code that encrypts/decrypts on every controller I used filters in that example. In this post I’ll use another complimentary technique: custom model binding.

OAuth 2 provides several flows or grant types for various use cases. I personally group them into two categories; flows that require user interaction with authorization server and flows that don’t.

Content Security Policy (CSP) is an additional level of security that could help prevent Cross Site Scripting (XSS) attacks. In these attacks malicious scripts are executed on user’s browser since browser doesn’t know whether the source of the script is trustworthy or not.

OWASP 2013 classifies Cross Site Request Forgery (CSRF) as one of the Top 10 risks and is present if attacker can force the victim's browser to send forged request to your web application and it considers it a legitimate request.

Configure ASP.NET Core Status Code Pages middleware to display custom error pages for HTTP status codes using re-execution or redirects.

How to prevent insecure direct object reference in ASP.NET Core.

When your controllers redirect to another location based on user input (e.g. via query string), it is important to ensure that the location is not malicious and prevent open redirect attacks. The simplest way to ensure this is by examining the URL provided by the user.

The new Data Protection API in .NET Core includes functionality to create hashes using PBKDF2algorithm. ASP.NET Core uses this behind the scenes in PasswordHasher class, which is used in ASP.NET Core Identity.

Create an empty project and update Startup to add services and middleware for MVC, including the filter for HTTPS.

To allow clients from a different origin to access your ASP.NET Core Web API, you’ll need to allow Cross-Origin Requests (CORS). Here same origin means clients who have identical schemes, hosts and ports.

Authorization is about deciding permissions users have and resources they can access. In ASP.NET Core this is achieved by first assigning claims to the user and then based on those claims defining policies to determine user permissions.

Bearer Tokens (or just Tokens) are commonly used to authenticate Web APIs because they are framework independent, unlike something like Cookie Authentication that is tightly coupled with ASP.NET Core framework.

Cookie Authentication allows developers to hook into events at various lifecycle stages of the authentication process. For instance you could log successful sign-ins using OnSignedIn or use OnValidatePrincipal (runs on every request) to invalidate the user (e.g. if you want to force sign-out).

The single biggest selling point of MVC architecture in general and ASP.NET Core in particular is that it makes testing much simpler. ASP.NET team has done a great job in making a framework that is pluggable, thus enabling testing of controllers, repositories and even the entire application a breeze.
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegisterMembers onlyWrite an article and earn +1,000 SHARP when it is approved.
Write an article