I have used reflection to get all pages in a mvc .net framework application. I have looked for controller/action combination to name the items in the pages list. How ever it brings back views and partial views and I am just interested in the main views. How can I get just the main pages with reflection? Note I am using this to dictate which users can view which pages.
Assembly asm = Assembly.GetExecutingAssembly();
var methods = asm.GetTypes()
.Where(type => typeof(Controller).IsAssignableFrom(type)) //filter controllers
.SelectMany(type => type.GetMethods())
.Where(method => method.IsPublic && !method.IsDefined(typeof(NonActionAttribute)));
Aucun commentaire:
Enregistrer un commentaire