- Home
- .NET code examples
- Basic Authentication in ASP.NET Core example
Basic Authentication in ASP.NET Core example
Download a Basic Authentication example in ASP.NET Core with Minimal API and controllers examples.
You can learn more by reading our Basic Authentication tutorial, or watching this video.
Download the code example
You'll need to fill out the code example form. We will send you an email where you can download the code example.
Software
This is the software that will need to be installed onto your machine.
Visual Studio 2026. Version 18.0.0 or above. It will work with the free community version.
.NET 10 SDK. Version 10.0.0 or above.
The application
Open up RoundTheCode.BasicAuthentication.slnx. The project should open in Visual Studio 2026.
Run the application.
You can use Postman to test the API endpoints with these endpoints using HTTP GET:
Minimal API -
https://localhost:7260/api/products/2Controllers -
https://localhost:7260/api/categories/2
In the Authorization tab, set the following options:
Authorisation Auth Type: Basic Auth
Username:
roundthecodePassword:
roundthecode
The requests will return 200 OK. If you change the username, password, or the Auth Type to something different, it will return 401 Unauthorized.
Related code examples