I followed this tutorial, which is very good: https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc?view=aspnetcore-2.1
There were some gotchas though, so (as always) I made notes:
- Whenever you add new code you have to stop running and rebuild before you can send successful requests.
- When you do a POST, the port number is 5001 or 5000: It’s whatever you’re using in the browser for GET requests
- When you add the Update method, you have to send another POST to create a new Todo item before you can update it. The url is the location field from the response of the POST.
- When you add the Delete method, use the GET request in the browser to find the Ids of existing items so you know what you can delete. The url is the same as the Update url, with appropriate Id added on. Use the GET request to check whether deletes have worked. Use the POST to add elements you can then delete.
- When you add a new database context you need to update the dependency injection stuff in Startup.cs and you need to make sure your POCO class has an Id property.
See also the following two posts:
- Adding NUnit tests to a .Net Core console app
- Converting a .Net Standard console app into a .Net Core console app
2 thoughts on “Getting Started with .Net Core, ASP and WebAPI”