Skip to main content
.NET Conf: Focus on Xamarin
Did you miss the special .NET Conf all about Xamarin, a tech that lets you build mobile apps all with C#? Watch the sessions on demand.


Build secure REST APIs on any platform with C#

REST APIs with .NET and 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.

public class PeopleController : ControllerBase 
    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; }
Command prompt
curl https://localhost:5001/people/all


Simple serialization

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, for endpoints that have unique requirements.

Authentication and authorization

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.

Command prompt
curl -H "Content-Type: application/json" -X POST -d "{'name':'Ana'}" https://localhost:5001/people/create -i

HTTP/2 202
public class PeopleApiController : ControllerBase 

    public ActionResult<Person> Get(int id) 
        var person = db.People.Find(id); 

        if (person == null) 
            return NotFound(); 

        return person; 

    public IActionResult Create(Person person) 
        return Accepted(); 

Routing alongside your code

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.

HTTPS by default

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.

Great tools for any platform

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!

Learn about .NET tools

Ready to Get Started?

Our step-by-step tutorial will help you get Web APIs with ASP.NET running on your computer.

Supported on Windows, Linux, and macOS