0
我已經創建了一個解決方案,並將四個項目添加到其中。
包含三個mvc站點(SiteA,SiteB,SiteC) 和一個公共核心類庫(名稱是核心項目)。 現在所有的mvc站點的控制器都被移到了核心項目中。 我將核心項目引用到這些mvc站點。 我嘗試在這些網站註冊路線。如何限制動作在特定命名空間中的動作?
站點A:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "AWebDefault",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "Core.AWeb.Controllers" }
);
網站B:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "BWebDefault",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "Core.BWeb.Controllers" }
);
思泰科:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "CWebDefault",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "Core.CWeb.Controllers" }
);
的問題是: 當我訪問的站點A,以及如何防止用戶vistit siteB控制器或SiteC控制器? 我想要的控制器只能在特殊命名空間中找到。無法在其他名稱空間中搜索。那麼如何解決呢?