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

Asp.net core MVC map url to controller and action

mpals
1#
mpals Published in 2017-12-07 13:36:20Z

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.414887 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO