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
Post a Comment