This project is licensed under the MIT license and copyright to Robert Cato
This is a simple example of me learning how to construct Web APIs using ASP.NET Core 2.1 Web API utilizing Microsoft SQL Server as the DB backend.
The User code was borrowed/modified from this Tutorial by Jason Watmore.
It builds off a simple To-Do API and adds User Authentication via JWT Tokens.
- Visual Studio - The Community Edition is free. You'll need .NET Core 2.1 and the ASP.NET Core Templates.
- Microsoft.EntityFrameworkCore.SqlServer - I used Microsoft SQL Server in this project, but due to EntityFramework, you could just as easily use another DB provider.
- Swashbuckle.AspNetCore - A really awesome package for documenting and testing APIs.
- BCrypt.Net-Next - For hashing passwords for users and password checking using BCrypt.
- Rename appsettings.json.sample to appsettings.json
- Edit appsettings.json to update your connection string for SQL Server and specify a random string for the secret.
- In the Package Manager Console (or a shell), change to the directory containing
TodoAPI.csproj
and run the following:
dotnet restore
dotnet ef database update
- At this point, you should have a table on your SQL Server Instance.
- Press
F5
in Visual Studio to run the project. You should see IISExpress appear in your system tray. - Navigate to https://localhost:44397/swagger/index.html in your browser (Your port number may vary.)
- If all has gone well, you should see the Swagger UI and the display of all the endpoints! Congrats!