【发布时间】:2016-07-04 19:59:06
【问题描述】:
我已创建 Api 控制器并尝试添加 1 个 api 方法,但在我的 api 方法上添加 Route 属性时出错:
这是我的方法:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
public class MyController : ApiController
{
[AllowAnonymous]
[HttpPost]
[Route("api/abc/Get")] //Getting error :type or namespace Route could not be found
public async Task<object> Get()
{
}
}
但是在 Route 属性上我得到了错误:
错误:找不到类型或命名空间路由
【问题讨论】:
标签: c# asp.net-web-api routing asp.net-web-api-routing