[英]Dotnet core 3.1 global routing rule
I write a project in dotnet Core 3.1, and all my controllers have the same attribute我在 dotnet Core 3.1 中编写了一个项目,并且我所有的控制器都具有相同的属性
[Route("api/[controller]")]
I wonder if there is a way to white this rule somewhere on a global level, like Startup.cs
我想知道是否有办法在全球范围内的某个地方消除此规则,例如
Startup.cs
I searched in the microsoft documentation and couldn't find the answer.我在微软文档中搜索并找不到答案。
You can create a controller like this and all other controllers must be inherit form this controller您可以像这样创建一个控制器,所有其他控制器必须从这个控制器继承
[Route("api/[controller]")]
public class ApiBaseController : ControllerBase
{
}
Another controllers should be like this另一个控制器应该是这样的
public class UsersController : ApiBaseController
{
}
public class OrderController : ApiBaseController
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.