How to get Action and Controller name in ASP.Net Core MVC app? -


how action , controller names in asp.net mvc core rc1 application in startup.cs?

i want create middleware , log information (i want log detailed response database, need action , controller info.) after following code in configure method of startup.cs -

 app.usemvc(routes => {      routes.maproute(             name: "default",             template: "{controller=user}/{action=index}/{id?}");  });  //want action , controller names here.. 

you'll want inject iactiondescriptorcollectionprovider service middleware. that, can use property actiondescriptors.items list of actiondescriptor, has route values action. if cast controlleractiondescriptor, you'll have access controllername , actionname.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -