【发布时间】:2014-03-25 05:55:22
【问题描述】:
我在 Account 控制器中有一个方法(使用 RoutePrefix("api/Account") 我想响应 api/users 而不是 api/account,所以我使用了 '~' 来覆盖它:
[HttpGet]
[AllowAnonymous]
[Route("~api/users/{name:alpha}/exists")]
public async Task<IHttpActionResult> UserExists(string name)
{
var res = await UserManager.FindByNameAsync(name);
if (res != null)
return Ok();
return BadRequest();
}
So when I try it out I get the response:
No HTTP resource was found that matches the request URI 'http://localhost:21975/api/users/johndoe/exists'
无论如何这应该可以工作,但由于某种原因它不是,任何人都可以提出原因吗?
【问题讨论】:
标签: c# asp.net .net asp.net-web-api asp.net-mvc-5