I need to get all areas that has been registered as list and all of their controllers as a sub list and the same thing for actions. something like this:
AdminArea
HomeController
Index
Add
...
OtherController
...
AnotherArea
HomeController
Index
...
...
I have checked the answer of this question, and this one, but they are not what i'm looking for. The first one return all the routes that has been registered and the second one return all controllers at once.
Update
Ok, with the below code i can get all the areas and with the answer of the second question i can get all the controllers, but i can't figure it out each controller belong to what area.
var areaNames = RouteTable.Routes.OfType<Route>()
.Where(d => d.DataTokens != null && d.DataTokens.ContainsKey("area"))
.Select(r => r.DataTokens["area"]).ToList()
.Distinct().ToList();
So here is what i came up with, it's exactly what i wanted. I hope it will be helpful.
For getting actions, i used this answer.
If you have any better ways, please let me know.