I was wondering if there is an implemented way to get a list of objects from RouteConfig.cs, where I would have actual aspx page name and it's friendly URL equivalent. We work with the pagename in URL a lot and it's a pain in the *** to always check if the URL contains aspx page name in the path or the friendlyURL, as those pages could technically be accessed using both ways.
So say I have this in RouteConfig:
routes.MapPageRoute(
"ResetPasswordRequestRoute",
"reset-password",
"~/Pages/PasswordResetRequestPage.aspx"
);
routes.MapPageRoute(
"PatientRegistrationPageRoute",
"registration",
"~/Pages/Registration.aspx"
);
I want to implement something like this:
List<PageNames> PageNames = GetPageNamesFromRouteConfig();
Where the expected result looks like this:
List<PageNames>() {
{ new PageNames(){
Page = PasswordResetRequestPage.aspx,
FriendlyURL = reset-password}
},
{ new PageNames(){
Page = Registration.aspx,
FriendlyURL = registration}
},
}
If it cannot be done, I guess I can always read the RouteConfig.cs manually as text and separate each item in it and get it from there, I was just searching for an easier solution.