T4MVC 和区域路线
我有以下区域路由注册方法:
/// <summary>
/// Registers the area.
/// </summary>
/// <param name="context">The context.</param>
public override void RegisterArea(AreaRegistrationContext context)
{
// terminal customer url
context.MapRoute("TerminalCustomer", "Terminal/Customer/{action}/{id}", new { controller = MVCt4.TerminalArea.Customer.Name, action = MVCt4.TerminalArea.Customer.ActionNames.Index, id = string.Empty });
// terminal inbound pattern url
context.MapRoute("TerminalInboundPattern","Terminal/InboundPattern/{action}/{id}",new { controller = MVCt4.TerminalArea.InboundPattern.Name, action = MVCt4.TerminalArea.InboundPattern.ActionNames.Index, id = string.Empty });
// terminal outbound pattern url
context.MapRoute("TerminalOutboundPattern","Terminal/OutboundPattern/{action}/{id}",new { controller = MVCt4.TerminalArea.OutboundPattern.Name, action = MVCt4.TerminalArea.OutboundPattern.ActionNames.Index, id = string.Empty });
// terminal inbound shipment url
context.MapRoute("TerminalInboundShipment", "Terminal/InboundShipment/{action}/{id}", new { controller = MVCt4.TerminalArea.InboundShipment, action = MVCt4.TerminalArea.InboundShipment.ActionNames.Index, id = string.Empty });
// terminal outbound shipment url
context.MapRoute("TerminalOutboundShipment", "Terminal/OutboundShipment/{action}/{id}", new { controller = MVCt4.TerminalArea.OutboundShipment, action = MVCt4.TerminalArea.OutboundShipment.ActionNames.Index, id = string.Empty });
}
它按原样工作正常,但是当我更改为类型安全并且没有像这样的神奇方法时:
context.MapRoute("TerminalOutboundShipment", "Terminal/OutboundShipment/{action}/{id}", MVCt4.TerminalArea.OutboundPattern.Index(), new {id = String.Empty});
我收到运行时错误?我在 global.asax 文件中有这段代码,它工作正常:
static public void RegisterRoutes(RouteCollection routes)
{
// do not allow any body access our our resources
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
// home url ok
routes.MapRoute("Default", "Home/{action}/{id}", MVCt4.Home.Index(), new {id = String.Empty});
}
在它不起作用的区域中,将主要的全局 asa 工作正常吗?
I have the following area route registration method:
/// <summary>
/// Registers the area.
/// </summary>
/// <param name="context">The context.</param>
public override void RegisterArea(AreaRegistrationContext context)
{
// terminal customer url
context.MapRoute("TerminalCustomer", "Terminal/Customer/{action}/{id}", new { controller = MVCt4.TerminalArea.Customer.Name, action = MVCt4.TerminalArea.Customer.ActionNames.Index, id = string.Empty });
// terminal inbound pattern url
context.MapRoute("TerminalInboundPattern","Terminal/InboundPattern/{action}/{id}",new { controller = MVCt4.TerminalArea.InboundPattern.Name, action = MVCt4.TerminalArea.InboundPattern.ActionNames.Index, id = string.Empty });
// terminal outbound pattern url
context.MapRoute("TerminalOutboundPattern","Terminal/OutboundPattern/{action}/{id}",new { controller = MVCt4.TerminalArea.OutboundPattern.Name, action = MVCt4.TerminalArea.OutboundPattern.ActionNames.Index, id = string.Empty });
// terminal inbound shipment url
context.MapRoute("TerminalInboundShipment", "Terminal/InboundShipment/{action}/{id}", new { controller = MVCt4.TerminalArea.InboundShipment, action = MVCt4.TerminalArea.InboundShipment.ActionNames.Index, id = string.Empty });
// terminal outbound shipment url
context.MapRoute("TerminalOutboundShipment", "Terminal/OutboundShipment/{action}/{id}", new { controller = MVCt4.TerminalArea.OutboundShipment, action = MVCt4.TerminalArea.OutboundShipment.ActionNames.Index, id = string.Empty });
}
It works fine as is, but when I change to the typesafe and no magic way of like this:
context.MapRoute("TerminalOutboundShipment", "Terminal/OutboundShipment/{action}/{id}", MVCt4.TerminalArea.OutboundPattern.Index(), new {id = String.Empty});
I get a runtime error? I have this code in the global.asax file and it works fine:
static public void RegisterRoutes(RouteCollection routes)
{
// do not allow any body access our our resources
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("favicon.ico");
// home url ok
routes.MapRoute("Default", "Home/{action}/{id}", MVCt4.Home.Index(), new {id = String.Empty});
}
In the areas it does not work put the main global asa it works fine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 code plex 网站上找到了有关如何使用 t4mvc 的示例。
codeplex
I found a example on how to use the t4mvc on the code plex site.
codeplex