This article builds on CRUD concepts (GET, POST, PUT, PATCH) and focuses on real-world API development with ASP.NET Core.
1. DELETE Method in ASP.NET Core Web API
What is DELETE?
The DELETE HTTP method is used to remove data from the server.
Real-life example:
Deleting a product from an online store's inventory.
Example Scenario: Delete a Product
Product Model
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
}
API Code (DELETE)
[HttpDelete("{id}")]
public IActionResult DeleteProduct(int id)
{
var product = products.FirstOrDefault(p => p.Id == id);
if (product == null)
return NotFound();
products.Remove(product);
return Ok($"Product with ID {id} deleted");
}
Input (Request)
DELETE /api/products/2
Output (Response)
"Product with ID 2 deleted"
After Deletion – GET Output
[
{ "id": 1, "name": "Laptop", "price": 1200 }
]
2. Testing Web API Using Postman (Step-by-Step)
What is Postman?
Postman is a tool used to test APIs by sending HTTP requests and viewing responses.
Step 1: Open Postman
Click New → HTTP Request
Step 2: Test GET
Method: GET
URL:
https://localhost:5001/api/products
Click Send
You will see JSON output.
Step 3: Test POST
Method: POST
URL:
https://localhost:5001/api/products
Body → Raw → JSON
{
"name": "Keyboard",
"price": 45
}
Click Send
New product is created.
Step 4: Test PUT
Method: PUT
https://localhost:5001/api/products/1
{
"name": "Gaming Laptop",
"price": 1500
}
Step 5: Test PATCH
Method: PATCH
https://localhost:5001/api/products/1
{
"price": 1400
}
Step 6: Test DELETE
Method: DELETE
https://localhost:5001/api/products/1
3. Using Real Database with Entity Framework Core
What is Entity Framework Core?
EF Core is an Object Relational Mapper (ORM) that lets you work with databases using C# classes instead of SQL.
Step 1: Install Packages
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools

Join the conversation! Your thoughts help the community grow.