1

I use asp.net mvc with route attributing and I get this error:

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);
        }
    }

Why is my route with localhost:5555/api/test with POST not found?

That is my default route setup:

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapMvcAttributeRoutes();
        }
HelloWorld
  • 4,671
  • 12
  • 46
  • 78

1 Answers1

0

The RouteAttribute should not have a leading ~.

TryingToImprove
  • 7,047
  • 4
  • 30
  • 39