我使用带有路由属性的asp.net mvc,我收到此错误:
System.Web.HttpException (0x80004005): No matching action was found on controller 'Test.RequestController'. This can happen when a controller uses RouteAttribute for routing, but no action on that controller matches the request.
public class TestController : Controller
{
[Route("~/api/test")]
[HttpPost]
public async Task<ActionResult> Post(TestRequest r)
{
return new HttpStatusCodeResult(HttpStatusCode.Created);
}
}
为什么我的路由与localhost:5555 / api / test没有找到POST?
这是我的默认路线设置:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
}
答案 0 :(得分:0)
RouteAttribute
应该不具有前导~
。