Rob*_*ett 5 tridion asp.net-mvc-4 dd4t tridion-2011
我正在使用DD4T框架与SDL Tridion 2011和ASP.NET MVC4
我有一些非DD4T控制器和视图,我想使用,但是当我尝试去这些网址时,我收到404错误.
这是我的路线表
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Route for SDL Tridion UI 2011 (Aka !SiteEdit)
routes.MapRoute(
"SiteEditBlankPage",
"se_blank.html",
new { controller = "Empty", action = "Index" });
routes.MapRoute(
null, // Route name
"xml/{*PageId}", // URL with parameters
new { controller = "Page", action = "Xml" }, // Parameter defaults
new { pageId = @"^(.*)?$" } // Parameter constraints
);
// Tridion page route
routes.MapRoute(
"TridionPage",
"{*PageId}",
new { controller = "Page", action = "Page" }, // Parameter defaults
new { pageId = @"^(.*)?$" } // Parameter constraints
);
routes.MapRoute(
null, // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试在Tridion上面移动默认路由,但后来我为Tridion页面获得了404s.
让它工作的唯一方法似乎是有一个特定的路径到我的控制器,例如:
routes.MapRoute(
null, // Route name
"MyController/{action}/{id}", // URL with parameters
new { controller = "MyController", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
有人有主意吗?由于上述解决方案并不理想.
(我的web.config中没有任何UI 2012配置)
AFAICS有几种选择:
如果你能从'普通'url(扩展名,startpath等)识别Tridion url,你可以通过调整TridionPage路由来解决它.但是我认为这不是你的选择,因为如果你能从正常人那里认出Tridion的url,你就已经想出了这个解决方案;)
在TridionPage路由上实现路由约束.如果请求的URL在Broker中,请检查此routeconstraint.如果为true:返回true,否则返回false.如果返回false,则下一个匹配的路由将处理该请求.虽然不确定性能.
您自己的选择:普通网页的特定路线.
我相信我错过了一些选择.希望其他人在这里分享他们.
正常的DD4T操作是让Tridion拥有URL,即捕获所有URL并将它们传递给一个PageController.这会干扰控制器/操作根据其名称自动路由,因此其中一个细节必须给出!
我个人喜欢阿尔伯特的第一个建议,因为它很简单.例如,只将以".html"结尾的网址映射到Tridion.不幸的是,这会导致SG中的默认页面出现问题,因为"/ sg"无法识别,即使您在代理中可能有"/sg/index.html".解决这个问题的一些替代方案:
为所有第一级结构组(/ news,/ products等)配置显式路由
将所有Tridion页面发布到您网站的子部分,例如/ content并将其映射到特定路径