【发布时间】:2022-01-08 22:24:45
【问题描述】:
在 ASP.NET MVC 项目中,我们有几个端点方法,其中为所有方法设置了一些标记,例如 ProducesResponseType((int)HttpStatusCode.OK) 标记。
有没有办法为类中的所有方法设置一些响应?
如您所见,四行代码仅用于状态代码
/// <summary> A summary describing the endpoint</summary>
[HttpPost("RenameSomething/", Name = "Rename[controller]")]
[Produces("application/json")]
[ProducesResponseType((int)HttpStatusCode.OK),
ProducesResponseType((int)HttpStatusCode.NotFound),
ProducesResponseType((int)HttpStatusCode.BadRequest),
ProducesResponseType((int)HttpStatusCode.InternalServerError)]
public ActionResult RenameSomething()
【问题讨论】:
标签: c# asp.net-mvc api swagger