gpt4 book ai didi

asp.net-mvc-4 - DD4T 默认路由不起作用

转载 作者:行者123 更新时间:2023-12-02 14:51:07 26 4
gpt4 key购买 nike

我将 DD4T 框架与 SDL Tridion 2011 和 ASP.NET MVC4 结合使用

我有一些想要使用的非 DD4T Controller 和 View ,但是当我尝试访问这些网址时收到 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
);
}

我尝试将默认路由移至 Tridion 之上,但随后 Tridion 页面出现 404 错误。

让它工作的唯一方法似乎是有一个到我的 Controller 的特定路由,例如:

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

大家有什么想法吗?由于上述解决方案并不理想。

(我的 web.config 中没有任何 UI 2012 配置)

最佳答案

AFAICS 有多种选择:

  1. 如果您可以从“正常”url(扩展名、起始路径等)中识别 Tridion url,您可以通过调整 TridionPage 路由来解决该问题。但我认为这对你来说不是一个选择,因为如果你能从普通的 URL 中识别出 Tridion url,你就已经想出了这个解决方案;)

  2. 在 TridionPage 路由上实现路由约束。如果请求的 url 在 Broker 中,请检查此路由约束。如果为 true:返回 true,否则返回 false。如果返回 false,则下一个(匹配的)路由将处理该请求。但不确定性能。

  3. 您自己的选择:正常页面的特定路线。

我确信我错过了一些选项。希望其他人在这里分享。

关于asp.net-mvc-4 - DD4T 默认路由不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13158180/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com