2014-11-22 62 views
0

我有一個帶有索引操作的MainController。我想在索引動作中傳遞請求url的最後一個片段。我已經試過這條路線:在ASP NET中創建自定義路由

routes.MapRoute(
      "Main", 
      "Main/#!/{alias}", 
      new { controller = "Main", action = "Index" } 
     ); 

與此索引操作:

public ActionResult Index(string alias) 
    { 
     // code 
    } 

,但是這是行不通的。錯誤在哪裏?

回答

0

這樣

routes.MapRoute(
      "Main", 
      "Main/#!/{alias}", 
      new { controller = "Main", action = "Index", alias= UrlParameter.Optional } 
     ); 
+0

不,那不是工作 – user4281465 2014-11-22 13:16:57