我有以下区域路线注册方法:
/// <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});
}
在它不起作用的领域把主要的全球化,因为它运作正常吗?