我有一个WebApi项目,我遇到了这种情况。假设我有一条路线:
[Authorize]
[RoutePrefix("api/v1/GG")]
public class StorkUserController : ApiController
{
private IAuthenticationManager Authentication
{
get { return HttpContext.Current.GetOwinContext().Authentication; }
}
[Route("UpdateUser")]
[HttpPost]
所以当我启动应用程序时,如果我直接在我的浏览器中输入这条路线:
http://localhost:52494/api/
我将通过一些细节获得此错误:
或者如果我导航到http://localhost:52494/api/v1/GG
我得到:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:52494/api/v1/GG/'.","MessageDetail":"No type was found that matches the controller named 'v1'."}
如何防止这种情况发生,因为可以很容易地找到这些路线,而不是显示“ERROR 404”之类的东西!谢谢!