Topics: General
Feb 14, 2012 at 10:34 PM

Coming from event driven programming background, I am struggling to figure out which part of the code is getting executed when certain UI elements are being clicked. Is there any way in orchard to determine what controller and action is getting fired up.  I am curious if there is any technique applied to determine this.



Feb 15, 2012 at 12:09 AM

It should be pretty plain by looking at the link url or form action, then comparing with routes.

Feb 15, 2012 at 3:19 PM

Pardon my ignorence, where are all the routes defined ? What I know

1) It should be defined in the global.asax

2) It should be define in Routes file in the root folder.

Where in Orchard project ?





Feb 15, 2012 at 3:29 PM

Typically you create Routes.cs in the root of your module, though it doesn't matter where you place it because Orchard will pick up your routes as long as the class implements the IRouteProvider interface. 

Here's an example, the Routes.cs from Orchard.Blogs

Feb 15, 2012 at 4:01 PM

If there is no Routes.cs defined for the modules what does that mean ?


Feb 15, 2012 at 6:05 PM

It means you haven't created it yet. 

Feb 15, 2012 at 6:36 PM

In MVC all the routes end up in the RouteCollection. Same is for Orchard because it uses MVC. But in Orchard we can't afford to declare them in the Global.asax because we need extensibility. So what is actually done is that we provide an interface IRouteProvider that you can implement to declare your routes in a module. then Orchard loads all those implementations for the active modules, in each active tenant, and at startup populates the RouteCollection with the results of those classes.