basic Controller question

1 month ago
I've developed a couple plugins for internal use and they are working just fine.  I always just copy another plugin to start and make needed changes.

To get a better understanding of what is going on - can I ask the group a newbie question?

So I have a class called "MyPluginController" that inherits from BasePluginController.  

In my RouteProvider.cs I map a route to the controller.  Like this:
         routeBuilder.MapRoute( "MyPlugin.DoSomething", "MyPlugin/DoSomething",  new { controller = "MyPlugin", action = "DoSomething" });

As I understand this, I have just created a route "MyPlugin/DoSomething" and given it default parameters of using the controller "MyPlugin" with an action of "DoSomething"

So......How does the system know to call MyPluginController class?   (In the MapRoute, the controller name is specified as "MyPlugin".)

I've searched the samples and can't see anywhere where a class is being "registered" as the handler for a given controller name.  But it works so what connects the MyPluginController class to the route controller named "MyPlugin"?
1 month ago
it's a feature of MVC:

The route template "{controller=Home}/{action=Index}/{id?}" can match a URL path like /Products/Details/5 and will extract the route values { controller = Products, action = Details, id = 5 } by tokenizing the path. MVC will attempt to locate a controller named ProductsController and run the action
1 month ago
Simple enough.  Thanks for filling in that blank for me.
1 month ago
OK if I'm understanding you correctly, the default action on the MapRoute method is really not important.   A path of  /Products/Details/5  will seek ProductsController class to handle the call.  

So if I specified on the MapRoute call 3rd parameter....
new { controller = "SomeOtherController", action = "SomeOtherAction" }

Are you saying /Products/Details/5 would *STILL* route to ProductsController?  Not SomeOtherControllerController?
1 month ago
"/Products/Details" is the example from the MS link above

{ controller = "SomeOtherController", action = "SomeOtherAction" } would match a URL path of /SomeOtherController/SomeOtherAction, and MVC would look for a SomeOtherAction method in the SomeOtherControllerController
1 month ago
Also, that "default" (first param) in the MS example is just the name of the route.  Its' not relevant to any action/method names.