[Practical collection of WEB APIs]-Introduction to WEB APIs (1)

Source: Internet
Author: User

[Practical collection of WEB APIs]-Introduction to WEB APIs (1)

As the first article of this series, this article provides a basic introduction. experienced people can jump to the second part to create ProductController.

 

Create a Web API Project

Here we use VS2013 and. NET 4.5.1 to create a Web API 2 project.

[RoutePrefix ("api/products")] public class ProductController: ApiController {[HttpGet, Route ("product/getList")] public Page <Product> GetProductList () {throw new NotImplementedException ();} [HttpGet, Route ("product/get")] public Product GetProduct (Guid productId) {throw new NotImplementedException ();} [HttpPost, route ("product/add")] public Guid AddProduct (Product product) {throw new NotImplementedException ();} [HttpPost, Route ("product/update")] public void UpdateProduct (Guid productId, Product product) {throw new NotImplementedException ();} [HttpDelete, Route ("product/delete")] public void DeleteProduct (Guid productId) {throw new NotImplementedException ();}}

Start the program after adding it. The result is as follows:

 

OK. Now you can add your own backend business logic to complete the operations at the business layer.

 

Code in this chapter: Download the code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.