I am introducing a new ASP.NET MVC 3 application that will use the dynamic routing form to determine which view is returned from the general controller action. I would like the view to display by default if there is no view in the dynamic location.
Think of it as navigating a tree structure. There is only one TreeController in the Controllers root folder. It has a browse action method that takes the node path to view. Each node can have a custom look, so I need to first try to find this view and return it from the action method, for example:
public ViewResult Browse(String path) { var model = ...; return View(path, model); }
So, if I go to "MySite / Tree / A / B / C", I would expect to find the view in "\ Views \ Tree \ A \ B \ C.aspx".
However, if there is no custom view, I need to refer to the standard default views (for example, "\ Views \ Tree \ Browse.aspx").
Since this applies only to this action method, I do not believe that I should handle NotFound errors that may arise due to other circumstances. And I'm not looking for dynamic routing, as described in other posts, because the path to the controller is fixed.
source share