Handling Singular and Plural Controllers/Routes

后端 未结 5 1800
忘了有多久
忘了有多久 2021-01-31 09:12

I\'m a little confused on how I should handle singular and plural routes and controllers in my web application.

The website is a simple quotes site - think Einstein, Sha

5条回答
  •  伪装坚强ぢ
    2021-01-31 09:49

    For WebAPI it should be plural. Microsoft has examples. In this examples for WebAPI it is plural. Here's links

    • https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-implementation (this is best practise),
    • https://docs.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api

    • https://docs.microsoft.com/en-us/odata/webapi/built-in-routing-conventions

    In first example it is OrdersController . In last 2 pages there is ProductsController which is in plural. Also REST naming convention strict with that. Links should be in plural. So simple way to accomplish this in c# is to create controller with plural name

    As for MVC it should be singular controller

提交回复
热议问题