2009-08-07 110 views

回答

2
routes.MapRoute("AllGETs", 
    "{*any}", 
    new { Controller = "YourController", Action = "YourAction" }, 
    new { HttpMethod = new HttpMethodConstraint("GET") } 
); 
+0

嗯...这似乎并没有工作。我浏览到localhost:4075/NewAccount并获取资源未找到。 – Crios 2009-08-07 19:44:56

+0

如果你的动作有参数(例如'string id'),添加默认路由:'new {Controller = ...,Id =“”}' – 2009-08-07 19:47:44

+0

并尝试将此路由放到RouteTable的顶部 – 2009-08-07 19:56:11

0

其实我结束了做这个,好像做什么,我需要:

routes.MapRoute(
    // Route name 
    "Default",    
    // URL with parameters 
    "{controller}/{id}", 
    // Parameter defaults 
    new {controller = "Home", action = "GenericPostHandler", id = "" } 
); 
相关问题