我只想要一个控制器动作来处理所有GET。如何绘制路线以进行此操作?
答案 0 :(得分:2)
routes.MapRoute("AllGETs",
"{*any}",
new { Controller = "YourController", Action = "YourAction" },
new { HttpMethod = new HttpMethodConstraint("GET") }
);
答案 1 :(得分:0)
我实际上最终做到了这一点,似乎做了我需要的事情:
routes.MapRoute(
// Route name
"Default",
// URL with parameters
"{controller}/{id}",
// Parameter defaults
new {controller = "Home", action = "GenericPostHandler", id = "" }
);