I would like to be able to have custom pages that are not tied to a controller. These custom pages will all be routed to a default controller. Then there are other pages that are not custom that have Controller classes set up as normal. I can't get the routing rules to work for both situations.
I have routing rules that look like this:
routes.MapRoute( _
name:="Default", _
url:="{controller}/{action}", _
defaults:=New With {.controller = "Home", .action = "Index"} _
)
routes.MapRoute( _
name:="Custom Page", _
url:="{name}", _
defaults:=New With {.controller = "Page", .action = "Index"} _
)
This situation works for the static controllers, but not the custom pages. It always tries to find the controller with the custom name (url:="{name}") which doesn't exist, so I get a "Resource not found" error.
If I reverse the rules, then the custom pages work correctly, but the static pages do not.
I know that the problem is that both rules overlap each other, so whichever one is first is always used. Ideally I would like to be able to tell the routing to look for a controller named X, if it exists use that. If it doesn't exist, redirect to Y controller and pass in X as a parameter. Right now if the controller does not exist, it doesn't continue to the next routing rule, it just says the resource cannot be found.
Is something like this possible?