【发布时间】:2017-04-03 15:27:16
【问题描述】:
是否可以在 MVC 中更改路由控制器名称?在 MVC 5 中我会这样做:
[RoutePrefix("MySpecialSauce")]
public class ProductsController : Controller
{
[Route("GetBy/{id}")]
public MyObject GetBy(int id)
{
return something(id);
}
}
现在我能找到的就是使用控制器的默认名称:
[Route("[controller]")]
public class ProductsController : Controller
{
[HttpGet("GetBy/{id}")]
public MyObject GetBy(int id)
{
return something(id);
}
}
我想为我的路由使用与实际控制器名称不同的名称。你是怎么做到的?
【问题讨论】:
标签: c# asp.net-core-mvc asp.net-core-routing