【发布时间】:2020-08-29 07:36:52
【问题描述】:
我希望在我的 API 中使用此方法,但它无效。
【问题讨论】:
-
您需要添加一个示例,说明您尝试过的操作以及遇到的错误。
-
我已更新我的问题以添加图像错误。
-
首先,请阅读How to ask并更新您的问题,以便其他人能够理解。
标签: c# class annotations
我希望在我的 API 中使用此方法,但它无效。
【问题讨论】:
标签: c# class annotations
如果您将ApiController 类继承到您的控制器,那么您可以使用this 运算符调用它
例如,
using System;
using System.Web.Http;
...
public class SampleController : ApiController
{
public IActionResult GetSample()
{
//Your code goes here
this.Validate(); //This is the way to call Validate method
}
}
【讨论】:
IActionResult 的正确命名空间。 MSDN 文档(.net 核心)docs.microsoft.com/en-us/dotnet/api/…