WHAT’S NEW IN .NET8

DOTNET 8 New and Efficient Way to Check IP is in Given IP Ranges

Sibeesh Venu
4 min readOct 13, 2023

The .NET 8 has introduced a new type IPNetwork with a Contains method. It retruns true if the given IPAddress is part of the IP network. Otherwise, returns false.

DOTNET 8 New and Efficient Way to Check IP is in Given IP Ranges

In our last post we have seen how we can restrict the access to your application by implementing IP restrictions using ActionFilterAttribute but we were checking the IP addresses and was missing a feature to support the IP Ranges. The good news is that the .NET 8 has a new and efficient way to do this. Here in this post, we will see how we can implement the same. Let’s begin.

Source Code

You can also see the codes in this repository.

Enablling .NET8 for Your Application

As you might have already guessed, the first step is to download the .NET8 from here. Let’s now change the TargetFramework in our both DotNetIpFilter.csproj and DotNetIpFilter.Test.csproj files. You can get the application code from the repositroy mentioned above.

<TargetFramework>net8.0</TargetFramework>

You will also need to update your Microsoft.AspNetCore.OpenApi package to .NET8.

Enable Preview .NET 8 in Visual Studio 2022

--

--

Sibeesh Venu

An engineer by profession and writer by passion. Author at Sibeesh Passion, Microsoft MVP (2016–2022). Software Engineer @ Microsoft