ASP.NET 5中的RoutePrefixAttribute

ale*_*xjk 17 c# asp.net-web-api2 dnx asp.net-core

我在ASP.NET 5中启动了一个新的Web API 2.0项目.我尝试创建自定义RoutePrefixAttribute类,但是我收到此错误

The type or namespace name 'RoutePrefixAttribute' could not be found 
(are you missing a using directive or an assembly reference?)   {ProjectName}.DNX Core 5.0
Run Code Online (Sandbox Code Playgroud)

我应该使用其他课吗?

Hen*_*ema 31

RoutePrefixAttribute在MVC 6中确实没有.在[Route]控制器上应用属性现在将充当路由前缀:

[Route("api/[controller]/[action]")]
public class ProductsController : Controller
{
    [Route("{id:int}")]
    public JsonResult Details(int id)
    {
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

这将匹配api/Products/Details/42.

另见Filip W.的博客文章