Home Asp.net core MVC map url to controller and action
Reply: 0

Asp.net core MVC map url to controller and action

user675 Published in July 16, 2018, 6:42 am

MVC uses routing by convention, but also custom routes where the url may include no clue as to what controller and action it will be mapped to. I know urls are mapped by the framework so that the correct controller/action is called but is there a way to programmatically access that mapping?

I have need of this in my custom logger where I want to be able to log which controller and action is being called.

For example: If I have a custon route where "/about" mapps to "/information/index" I would like to be able to get that information in my code.

"localhost/about" => "InformationController.Index"

or some similar output.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.412514 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO