c# – RoutePrefixAttribute在ASP.NET 5中
发布时间:2020-12-15 03:43:07 所属栏目:百科 来源:网络整理
导读:我在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?) {Pr
我在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 我应该使用其他类吗? 解决方法
MVC中确实没有RoutePrefixAttribute 6.在控制器上应用[Route]属性现在将作为路由前缀:
[Route("api/[controller]/[action]")] public class ProductsController : Controller { [Route("{id:int}")] public JsonResult Details(int id) { // ... } } 这将匹配api /产品/细节/ 42. 也见Filip W. this blogpost. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |