ASP.NET Web APIs
Build secure REST APIs on any platform with C#
ASP.NET makes it easy to build services that reach a broad range of clients, including browsers and mobile devices.
With ASP.NET you use the same framework and patterns to build both web pages and services, side-by-side in the same project.
[ApiController]
public class PeopleController : ControllerBase
{
[HttpGet("people/all")]
public ActionResult<IEnumerable<Person>> GetAll()
{
return new []
{
new Person { Name = "Ana" },
new Person { Name = "Felipe" },
new Person { Name = "Emillia" }
};
}
}
public class Person
{
public string Name { get; set; }
}
curl https://localhost:5001/people/all
[{"name":"Ana"},{"name":"Felipe"},{"name":"Emillia"}]
ASP.NET was designed for modern web experiences. Endpoints automatically serialize your classes to properly formatted JSON out of the box. No special configuration is required. Of course, serialization can be customized for endpoints that have unique requirements.
Secure API endpoints with built-in support for industry standard JSON Web Tokens (JWT). Policy-based authorization gives you the flexibility to define powerful access control rules—all in code.
curl -H "Content-Type: application/json" -X POST -d "{'name':'Ana'}" https://localhost:5001/people/create -i
HTTP/2 202
[ApiController]
public class PeopleApiController : ControllerBase
{
// Some code omitted for clarity
[HttpGet("people/{id}")]
public ActionResult<Person> Get(int id)
{
var person = db.People.Find(id);
if (person == null)
{
return NotFound();
}
return person;
}
[HttpPost("people/create")]
public IActionResult Create(Person person)
{
db.Add(person);
db.SaveChanges();
return Accepted();
}
}
ASP.NET lets you define routes and verbs inline with your code, using attributes. Data from the request path, query string, and request body are automatically bound to method parameters.
You don't deploy your apps without security, so why test them without security? ASP.NET provides first class support for HTTPS out of the box. Automatically generate a test certificate and easily import it to enable local HTTPS so you run, and debug, your apps the way they are intended to be... secured.
Our beginner's guide to building Web APIs with ASP.NET Core is designed to provide you with the foundation you need to start building Web APIs with .NET in a collection of short, pragmatic collection of videos.
Using Power Apps, anyone can build professional-grade business applications with low-code. Extend Power Apps further as a professional developer with custom connectors and logic. Learn how to build these services using OpenAPI-enabled ASP.NET Web APIs and make them available to Power Apps creators.
Build, debug, and deploy from any platform to any platform.
Issues in production? Not a problem... simply attach the debugger to your production instance and debug from your laptop!
Our step-by-step tutorial will help you get Web APIs with ASP.NET running on your computer.