다음 경로가 지정되었습니다. - MyHttpMethodConstraint는 폼에 의해 재정의 된 HTTP 메서드를 검사하는 것입니다.HTTP 메서드 제약 조건을 사용하여 잘못된 경로를 선택하는 링크에 대한 ASP.NET MVC URL 생성
routes.MapRoute("Retrieve", "{controller}/{id}/{action}", new { action = "retrieve" }, new { action = "create|retrieve|update|delete", httpMethod = new MyHttpMethodConstraint("GET", "HEAD"), id = new GuidRouteConstraint() });
routes.MapRoute("Update", "{controller}/{id}", new { action = "update" }, new { action = "update", httpMethod = new MyHttpMethodConstraint("PUT"), id = new GuidRouteConstraint() });
routes.MapRoute("Delete", "{controller}/{id}", new { action = "destroy" }, new { action = "delete", httpMethod = new MyHttpMethodConstraint("DELETE"), id = new GuidRouteConstraint() });
routes.MapRoute("Create", "{controller}", new { action = "create" }, new { action = "create", httpMethod = new MyHttpMethodConstraint("POST") });
모든게 내가 대신에 구속 된 사람을 찾는 (HTTP GET 방식으로 제한하는 경로를 사용하여) 기대 한대로 작동하지 않는 Url.ActionLink의에 대한 그러나 URL 생성, 작업에 제대로 들어오는 라우팅 POST/PUT/DELETE 그리고 잘못된 URL. 나는 경로를 다시 주문하려고 시도했지만 도움이되지 않습니다. 나는 그 URL 생성이 제약을 무시할 것으로 기대한다.
내 ActionLink 방법을 구축하는 것 외에 다른 해결 방법이 있습니까?
편집
목록의 맨 아래에 기본 경로도 있습니다 :
해결routes.MapRoute("Default", "{controller}/{action}", new { controller = "home", action = "index" });
MyHttpMethodConstraint의 코드를 제공 할 수 있습니까? HttpMethodConstraint가 실행하지 않는 것은 무엇을 하는가? – danludwig
답변에 대한 내 의견보기 - 표준 HttpMethodConstraint는 X-HTTP-Method-Override를 처리하지 않습니다. –