2011-10-26 35 views
0

我在項目中有幾個區域。在一個區域中,我有一個頁面(剃鬚刀),並在其中添加了RenderAction()方法。
RenderAction錯誤 - 路由表中沒有路由匹配提供的值

@{Html.RenderAction("Index", "Forum");} 

應用作品,但是當我在調試模式下,錯誤在此行我的代碼運行中斷(波紋管),我按下去,一切工作,但我必須刪除此錯誤。

No route in the route table matches the supplied values 

在Global.asax中添加以下路由,但它不能解決錯誤。

routes.MapRoute(
       "Forum", 
       "{area}/{controller}/{action}/{id}", 
       new { area = "Forum", controller = "Home", action = "Index", id = UrlParameter.Optional }); 

它的工作,但我真的不知道如何?
添加以下代碼在Global.asax中的RegisterRoutes()方法:

routes.MapRoute(
       "Forum", // Route name 
       "{area}/{controller}/{action}/{id}", // URL with parameters 
       new { controller = "Forum", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
      ); 

回答

2

嘗試將area路線參數:

@{Html.RenderAction("Index", "Home", new { area = "forum" });} 
+0

我已經試過這一點,這是行不通的。看到我的問題的結尾。我實際上解決了這個問題,但我可能不確定我在這裏做了什麼。 – 1110

+0

謝謝! 這解決了我的問題。處理錯誤重定向時,我使用了共享_layout。 – Jaans

相關問題