• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
PowerCoder
博客园    首页    新随笔    联系   管理    订阅  订阅

ASP.NET Core Web API官方文档(链接)

下面这篇微软官方文档,介绍了构建ASP.NET Core Web API的一些细节:

Create web APIs with ASP.NET Core

其中这里有提到一个特性类ApiControllerAttribute,实际上这个特性类在ASP.NET Core Web API的Controller上并不是必须的,但是使用它之后可以带来很多好处,使得开发人员获得更好的体验。对于ApiControllerAttribute特性类的使用,还可以查看:讲一下Asp.net core MVC2.1 里面的 ApiControllerAttribute

 

关于在ASP.NET Core Web API中,Controller的Action方法能返回的类型,可以查看这篇微软官方文档:

Controller action return types in ASP.NET Core web API

可以通过这篇文章了解,如何在ASP.NET Core Web API中,格式化Controller的Action方法的返回数据:
Format response data in ASP.NET Core Web API

 

下面这两篇文章介绍了ASP.NET Core的路由机制:

Routing to controller actions in ASP.NET Core

Routing in ASP.NET Core

特别是这里讲到了在Rest API中使用RouteAttribute:

Attribute routing for REST APIs

这里还讲了可以将HTTP verb Attribute和RouteAttribute混合使用:
Combining attribute routes

里面这句话很重要:

 Any route templates defined on the controller are prepended to route templates on the actions.

 

可以参考这篇文章了解,为ASP.NET Core Web API启用Swagger / OpenAPI:

ASP.NET Core web API help pages with Swagger / OpenAPI

如何在ASP.NET Core中通过Swashbuckle来启用Swagger,可以参考:

Get started with Swashbuckle and ASP.NET Core

 

posted @ 2020-06-17 14:42  PowerCoder  阅读(837)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3