it can be a different method. As a result, i want to get all the urls from the application.
I planning authorization in the my application. And, I need these (area name, controller name, action name) to ask when a request is made. In short, the URL address. I tried these.
Example:
- Trial (AreaRegistration)
- Trial1Controller
- Home ActionResult >>> /Trial/Trial1/Home/
- A ActionResult >>> /Trial/Trial1/A/
- B ActionResult >>> /Trial/Trial1/B/
- Trial2Controller
- Examp (AreaRegistration)
- Examp1Controller
- Home ActionResult >>> /Examp/Examp1/Home/
- A ActionResult; >>> /Examp/Examp1/A/
- Examp2Controller
- Home ActionResult >>> /Examp/Examp2/Home/
var areas = Assembly.GetExecutingAssembly().GetTypes().Where(type => typeof(AreaRegistration).IsAssignableFrom(type)).ToList();
foreach(var area in areas)
{
var controllers = Assembly.GetExecutingAssembly().GetTypes().Where(type => typeof(Controller).IsAssignableFrom(type)).ToList();
foreach (var controller in controllers)
{
var methods = controller.GetMethods(BindingFlags.Public | BindingFlags.Instance);
foreach (var method in methods)
{
if (method.ReturnType == typeof(ActionResult))
{
lstControllerActions.Add(string.Format("Area -> Controller -> Action : {0} -> {1} -> {2}", area.Name, controller.Name, method.Name));
}
}
}
}
lstControllerActions Result:
- Area -> Controller -> Action : Trial -> Trial1 -> Home
- Area -> Controller -> Action : Trial -> Trial1 -> A
- Area -> Controller -> Action : Trial -> Trial1 -> B
- Area -> Controller -> Action : Trial -> Examp1 -> Home
- Area -> Controller -> Action : Trial -> Examp1 -> A
- Area -> Controller -> Action : Trial -> Examp2 -> Home
- Area -> Controller -> Action : Examp-> Trial1 -> Home
- Area -> Controller -> Action : Trial -> Trial1 -> A
- Area -> Controller -> Action : Trial -> Trial1 -> B
- Area -> Controller -> Action : Trial -> Examp1 -> Home
- Area -> Controller -> Action : Trial -> Examp1 -> A
- Area -> Controller -> Action : Trial -> Examp2 -> Home
Everything is beautiful but, No connection controller between area.