asp.net Core mvc hide and exclude Web Api Controller Method

后端 未结 1 1399
Happy的楠姐
Happy的楠姐 2021-02-08 08:27

I know there is the ApiExplorerSettings attribute

[ApiExplorerSettings(IgnoreApi = true)]
public async Task MyMethod(int id)


        
相关标签:
1条回答
  • 2021-02-08 08:55

    The simplest MVC approach might be to use the NonAction attribute, like so:

    [ApiExplorerSettings(IgnoreApi = true)]
    [NonAction]
    public async Task<IActionResult> MyMethod(int id)
    

    Another option is to just change the method's access modifier from public to e.g. private for the same effect.

    If you'd like to exclude an entire controller, there's the NonController attribute:

    [NonController]
    public class MyController : ControllerBase
    
    0 讨论(0)
提交回复
热议问题