Does the approach of route matching for child actions differ from usual actions? In other words, do child actions have some autogenerated url to make matching similar to what is done for parent actions?
Does the approach of route matching for child actions differ from usual actions? In
Share
No difference between parent or child action processing
Any action follows the same route definition you’ve set in your
Application_Start. That means parent actions as well as child ones. If you gave specific routes for all actions in your application, then you must provide route definitions for your child actions as well.Avoid route processing by converting to
Html.RenderPartial()If you can of course… Child actions go through the same MVC processing as parent actions. It’s of course different if you can change your
Html.RenderAction()toHtml.RenderPartial(). These don’t go through the same processing hence are much much faster. UseHtml.RenderAction()only when you can’t do it any other way or doing it in other way would be to hackish (increased complexity of the view’s model type etc).Actual
Html.RenderAction()code excerptIf you look at the code of
Html.RenderAction()it calls into context processing to execute as if a request was made to the server:We can se that it uses
ChildActionMvcHandlerhandler which is inherited fromMvcHandler, but is basically no different from it in terms of execution, because it doesn’t have any new or changed functionality related to processing. So it executes MvcHandler’s code basically.Outcome?
Child actions execute as parent actions, using the same routing definitions, controller action matching (action method selectors), filters etc.