2009-08-07 109 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 = "" } 
); 
相關問題