Documentation/tutorial on routing in custom modules

Topics: Writing modules
Apr 2, 2012 at 5:03 PM

Hi, I'm new to Orchard and, for that matter, MVC3 and routing. I took my first stab at a custom module that includes a custom Routes class. It's working pretty well calling and executing http://<orchard_site>/<area>/<controller>/<action>. For some reason, though, it wants to resolve a URL at the end of that route request that is essentially the namespace (area) of the new module, ie: http://<orchard_site>/<area> which fails as expected with a 404 not found error.

I suspect that I could control for this via the appropriate routedescriptor object in IEnumerable<RouteDescriptor> GetRoutes() in the Routes class, but I don't really fully understand how to effectively leverage the default, constraint, and dataTokens values for the routedescriptor. So I was wondering if anyone could point me to a good resource to get a basic grasp on how to apply that.

Thanks in advance for any tips/info on this!

Apr 3, 2012 at 3:54 AM

Your best bet is to look at how other modules are doing it by reading their routes.cs.

Apr 4, 2012 at 3:37 PM

OK. Meanwhile, if anyone with familiarity re routes and modules can suggest why the namspace/area (ie:http://<orchard_site>/<area>) is even being requested, when the path referenced in the link is http://<orchard_site>/<area>/<controller>/<action>, I would be in their debt. Thanks!

Apr 4, 2012 at 3:47 PM

Not sure i understand your question. It sounds like your link  has /area/controller/action, but when you click it, it gets routed to /area. If that's the case then you need to fix your routes because for some reason the "/area/controller/action" URL is not matching the Route you expect it to. Could be a problem with the way the route is set up, or the route order/priority. 

Apr 4, 2012 at 4:19 PM

Thanks for the input! I just figured it out and, as is so often the case, I was causing my own problem. I had used an inappropriate object reference in the form view that then passed the area as a return URL. Now fixed that and problem solved. Thanks again!