Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a new service, use ASP.NET Core Web API: it supports RESTful APIs built with controllers or Minimal APIs. Use ASP.NET Web API 2 only when maintaining an existing .NET Framework application; its Visual Studio 2017 tutorial is legacy guidance, not the default setup for a new project.

Choose the right ASP.NET Web API generation

Option Best fit Controller base API styles covered by Microsoft’s guidance
ASP.NET Web API 2 Maintaining an existing .NET Framework application ApiController The cited guide covers controllers
ASP.NET Core Web API Developing a new service on the current ASP.NET Core stack ControllerBase Controllers and Minimal APIs

Microsoft’s current overview says, “ASP.NET Core supports creating RESTful services, also known as web APIs, using C#.” See Create web APIs with ASP.NET Core. This article follows the controller approach because it maps directly to the title’s Web API framing; Minimal APIs are also a supported choice.

Develop a controller-based service with ASP.NET Core

Follow Microsoft’s current Create a web API with ASP.NET Core tutorial for project setup and its current template and SDK prerequisites. The example below illustrates the essential resource-and-route structure rather than substituting for the tutorial’s complete project.

1. Model a resource and its data

Represent the thing your API exposes as a model, then connect it to a data context. Microsoft’s controller tutorial demonstrates this with a database context. Its sample uses an in-memory database, so data does not persist after the application restarts; use a suitable persistent data source when the service must retain changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech B100 Ambidextrous Wired Mouse - Black
  • A comfortable, ambidextrous shape feels good in either hand, so you feel more comfortable as you work-even at the end of the day
  • With 800 dpi sensitivity, you'll get precise cursor control so you can edit documents and navigate the Web more efficiently
  • Side-to-side scrolling plus zoom lets you instantly zoom in or out and scroll horizontally and vertically; perfect for working with spreadsheets and presentations.
  • Zero setup with flexible connectivity means you just plug it into your USB or PS/2 port-it works right out of the box
  • This mouse is built by Logitech-the mouse experts; it comes with the quality and design we've built into more than a billion mice, more than any other manufacturer

2. Add a controller for API requests

For an API controller, derive from ControllerBase. It contains request-handling behavior for APIs; the MVC Controller class adds view support, which an API that returns data rather than views generally does not need. See Microsoft’s API overview.

3. Map HTTP methods to resource operations

Use explicit route and HTTP-method attributes to connect requests to actions. A route placeholder such as {id} represents a value supplied in the URL. A typical resource shape has a collection route and an item route:

Rank #2
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use
  • GET /api/products retrieves the collection.
  • GET /api/products/{id} retrieves one item.
  • POST /api/products creates an item.
  • PUT /api/products/{id} updates an item.
  • DELETE /api/products/{id} removes an item.

These are the collection and item operations demonstrated in Microsoft’s controller tutorial. The attributes make the request-to-action mapping explicit; the route identifies the resource, while the HTTP method expresses the operation.

4. Return an appropriate result when an item is missing

When an item lookup finds no matching record, return a not-found response rather than treating the request as a successful retrieval. The Microsoft tutorial demonstrates this behavior for an item route. Apply the same distinction when implementing other operations: a request for a resource that does not exist should not be presented as though it succeeded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Maintain an existing ASP.NET Web API 2 application

ASP.NET Web API 2 is the older framework built on .NET Framework. Microsoft’s Get Started with ASP.NET Web API 2 (C#) describes a Visual Studio 2017 project, a Web API project reference, a model, and a controller derived from ApiController. The page was updated on September 29, 2022, and the tutorial itself directs readers to a newer ASP.NET Core version.

In that legacy tutorial, GetAllProducts maps to /api/products, while GetProduct maps to /api/products/{id}; a missing product returns not found. Its introductory sample stores products in a fixed in-controller array for demonstration. Microsoft recommends querying a database or another external data source for a real application. Do not copy the Visual Studio 2017 and Web API 2 setup as the starting point for a new ASP.NET Core service.

Quick Recap

SaleBestseller No. 1
Logitech B100 Ambidextrous Wired Mouse - Black
Logitech B100 Ambidextrous Wired Mouse - Black
Product carbon footprint: 1.73 kg CO2e
$6.99
Bestseller No. 2
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$9.70
SaleBestseller No. 3
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$14.90
Best Value
TECKNET Compact Ambidextrous Wireless Mouse for Laptop Mint Green
  • 【Special Mint Green Mouse】This is an ideal choice if you need a colorful and cute mouse. Special mint green color and compact size makes it the best mouse for kids and people with small hands.
  • 【Portable Small Mouse】 Only 3.94*2.28*1.52 inches, the usb mouse is designed for small to medium sized hands to achieve optimal fit and comfort. Portable design makes it easy to store in a bag for traveling.
  • 【Soft Click Quiet Mouse】 Responsive buttons and scroll wheel provide very soft click with less noise, no more disturbing others and bring you comfortable using experience.
  • 【Easy to Use Laptop Mouse】 2.4GHz wireless technology ensures reliable connectivity up to 49ft. 3 adjustable DPI levels (1600/1200/800) to meet your different needs. Only need 1xAA battery (NOT included) to support up to 15 months battery life.Note:USB connector is stored inside the back compartment (open the cover to access).
  • 【Universal Compatibility】The wireless mouse is well compatible with Windows11/10/8.1/7,Mac OS . Fits for desktop, laptop, PC, and other devices.
Rank #4
Lenovo 100 Wired USB Computer Mouse for PC, Laptop, Computer with Windows - Full-Size - Ambidextrous Design - 3 Buttons - Red Optical Sensor – Black
  • Slim and Comfortable Design: The Lenovo 100 Wired USB Mouse boasts a slim grip full-size mouse with an ambidextrous design, ensuring a comfortable fit in your hand, whether you're left or right-handed.
  • Built to Last: Rest assured about durability with the Lenovo 100 Wired USB Mouse. It's engineered for a 3 million clicks button life, delivering long-lasting performance that stands the test of time.
  • Reliable Wired Connection: Enjoy an easy and reliable connection to your PC via a 1.7-meter USB-A cable. No need to worry about signal drop-offs or battery replacements; this mouse is always ready for action.
  • Precision and Smooth Movement: The Lenovo 100 Wired USB Mouse offers precise movement with its 1000 DPI resolution and red optical sensor. Glide smoothly from window to window, ensuring accurate and efficient navigation.
  • Plug-and-Play Convenience: This hassle-free mouse is designed for productivity. It features a straightforward plug-and-play connection to PCs with a USB-A cable, making it a practical choice for users seeking a reliable and efficient pointing device.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.