ASP MVC Razor 渲染部分未找到正确的路由详细信息
我正在尝试运行 @{ Html.RenderAction("List", "Template"); }
在我的父视图中。
我的父视图映射到
我已注册使用的控制器 = EmailTemplateHost Action = Index:
routes.MapRoute(
"TemplateIndex",
"Template",
new { controller = "EmailTemplateHost", action = "Index" }
);
控制器 = EmailTemplateList action = List
模板/列表应映射到我已注册使用的
routes.MapRoute(
"TemplateList",
"Template/List",
new { controller = "EmailTemplateList", action = "List" }
);
:所有路由都在 RouteTable 中。然而,在渲染我的索引页面时,当它点击 RenderAction 时,它会点击 Windsor Controller Factory,询问 Template 的控制器名称,而不是 EmailTemplateList。看起来好像它没有通过路由引擎。如果我查看请求上下文,路由数据值将显示字典中的模板和列表,但它不会显示找到正确控制器所需的映射。
哦,是的,如果我使用 @{ Html.RenderAction("List", "EmailTemplateList");它
有效!
有什么想法吗?
谢谢乔纳森。
I am trying to run @{ Html.RenderAction("List", "Template"); }
in my parent view.
My parent view maps to controller = EmailTemplateHost Action = Index
Which I have registered using:
routes.MapRoute(
"TemplateIndex",
"Template",
new { controller = "EmailTemplateHost", action = "Index" }
);
Template/List should map to controller = EmailTemplateList action = List
Which I have registered using:
routes.MapRoute(
"TemplateList",
"Template/List",
new { controller = "EmailTemplateList", action = "List" }
);
All of the routes are in the RouteTable. However upon rendering my Index page when it hits the RenderAction it hits the Windsor Controller Factory asking for the controller name of Template and not EmailTemplateList. It seems as if it isn't going through the routing engine. If I look in the request context the route data values is showing Template and List in the dictionary but it is not showing the mapping I require to find the correct controller.
Oh yea if I use @{ Html.RenderAction("List", "EmailTemplateList"); }
It works!
Any thoughts?
Thanks Jonathan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将第二个路由 TemplateList 放在 global.asax 中的 TemplateIndex 路由上方。
Put the second route TemplateList above the TemplateIndex route in your global.asax.