I'm building a test center for various unit tests on my personal library and I wanted to have an easy-to-access route for a test API. So I have two entries in my route config: the default and my custom route...
routes.MapRoute(
name:="Default",
url:="{controller} / {Action} / {id}",
defaults:=New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional}
)
routes.MapHttpRoute(
name:="UnitTests",
routeTemplate:="test/{category}/{testname}",
defaults:=New With {.controller = "TestApis", .action = "testme",
.category = "TestCategoryOne", .testname = UrlParameter.Optional}
)
The idea was that whenever I want to make a call to my test API controller, I'll just prepend the URL with "test/" and it would know to redirect it to my "TestApisController" . . . but it seems to have broken my Default route.
QUESTION
Is there a way by which I can map all routes that start with "test/" to a specific controller while at the same time not breaking my default route?
EDIT
So after some time, I realized that the reason this method wasn't working had nothing to do with the route. I had another default API route defined in the "WebApiConfig" file that was causing some issues. I apologize, I am still transitioning from Webforms to MVC.