似乎我仍然缺少MVC路由概念。我有一条路线跟随一个区域中的另一条路线几乎相同的路线,但出于任何理由我每次尝试运行它时都得到404。我试图使用Phil Haack的Route Tester DLL并根据它命中正确的路线(匹配路线出现在common / itemhistory / {contentid})。当我试图将它真实地运行时,它会爆炸。
我正在尝试通过传递Guid将调用映射到JsonResult。我已经取得了成功,其他路线工作正常(常见的是我网站上的一个区域)。
我可能做错了什么?
context.MapRoute(
"ItemHistory",
"common/itemhistory/{contentid}",
new { controller = "common", action = "GetItemHistory" },
new { contentid = @"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$" }
);
context.MapRoute(
"Common_default",
"common/{action}",
new { controller="common", action = "Index" }
);
答案 0 :(得分:0)
您正在为“ GetItemHistory ”指定操作属性,并在常规路由模式中定义了 itemhistory 。看起来您的控制器中没有名称为“ GetItemHistory ”
的方法