Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple ASP.NET Core Web API controller for managing Todo items.
// Controllers/TodoController.cs
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace WebApiExample.Controllers {
[ApiController]
[Route("api/[controller]")]
public class TodoController : ControllerBase {
private static List<Todo> todos = new List<Todo> {
new Todo { Id = 1, Title = "Sample Task", Completed = false }
};
[HttpGet]
public IEnumerable<Todo> Get() => todos;
[HttpPost]
public ActionResult<Todo> Post(Todo todo) {
todo.Id = todos.Count + 1;
todos.Add(todo);
return CreatedAtAction(nameof(Get), new { id = todo.Id }, todo);
}
}
public class Todo {
public int Id { get; set; }
public string Title { get; set; }
public bool Completed { get; set; }
}
}ASP.NET Core is a modern, cross-platform, high-performance framework for building web applications, APIs, microservices, and cloud-based applications using .NET. It unifies the previous ASP.NET frameworks into a single, modular platform.
Origin & Creator
Developed by Microsoft and initially released in 2016, ASP.NET Core represents a complete rewrite of ASP.NET to support cross-platform, modular, and high-performance web development.
Industrial Note
ASP.NET Core is often used in enterprise environments, cloud-native applications, and high-performance APIs where scalability, security, and maintainability are critical.