2015-07-10 60 views
0

如何通過圖路線在asp.net mvc的改變區域將「admin」 seprate項目像圖片 enter image description here如何通過圖路線在asp.net mvc的改變區域seprate項目

我正在使用的代碼:

namespace App.Web 
    { 
     public class RouteConfig 
     { 
      public static void RegisterRoutes(RouteCollection routes) 
      { 
       routes.IgnoreRoute("{resource}.axd/{*pathInfo}");  

       var route = routes.MapRoute(
        "Admin_default", 
        "Admin/{controller}/{action}/{id}", 
        new { controller = "Home", action = "Index", area = "Admin", id = "" }, 
        new[] { "app.Admin.Controllers" } 
       ); 
       route.DataTokens["area"] = "Admin"; 

       routes.MapRoute(
        name: "Default", 
        url: "{controller}/{action}/{id}", 
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
       ); 

      } 
     } 
    } 

但在瀏覽器中輸入url時:http://localhost:27824/admin/home/index => show app.Web.Controllers-> home-> index !! (app.Admin.Controllers->首頁>指數沒有顯示!!)

enter image description here

回答

0

您不能路由到不同的項目。路線是項目特定的。

+0

nopcommerce劑量是如何做到的?(https://nopcommerce.codeplex.com/SourceControl/latest) – sepehr

+0

不確定你在說什麼,但他們不是在項目之間進行路由。如果你只是試圖獲得一個URL,那麼只需從另一個項目中檢索路由配置是可能的,但這並不重要。你必須使用反射來加載其他項目的程序集並使用它來創建一個UrlHelper,但是你甚至只能用它來獲取相對的URL。如果項目位於另一個域或虛擬目錄中,則無法從另一個項目中知道該項目。 –