在果园文档中有一个很好的指南,可供Creating an Orchard Module that uses its own controllers使用。
下面是从指导创建一个名为HelloWorld的模块航线采取了代码示例:如果您创建一个实现IRouteProvider可以让果园知道你的控制器路由类
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Routes;
namespace HelloWorld {
public class Routes : IRouteProvider {
public void GetRoutes(ICollection<RouteDescriptor> routes) {
foreach (var routeDescriptor in GetRoutes())
routes.Add(routeDescriptor);
}
public IEnumerable<RouteDescriptor> GetRoutes() {
return new[] {
new RouteDescriptor {
Priority = 5,
Route = new Route(
"HelloWorld",
new RouteValueDictionary {
{"area", "HelloWorld"},
{"controller", "Home"},
{"action", "Index"}
},
new RouteValueDictionary(),
new RouteValueDictionary {
{"area", "HelloWorld"}
},
new MvcRouteHandler())
}
};
}
}
}
。
与任何MVC操作一样。不要忘记指定该区域作为模块的文件夹名称。 – 2013-02-22 09:06:42
模块文件夹是* Comair.RI *。它有一个'HomeController'和'Index'操作,我有一个'Home/Index'视图。当我尝试url http:// orchard-multi/Comair.RI/Home/Index'时,我得到了Orchard'Not found'错误。没有错误日志。我不知道为什么没有找到。 – ProfK 2013-02-22 09:17:24