I have a complicated set of routes and I need to edit a specific web page. Given a URL, how do I determine which controller and view created that page?
I'm open to using ASP.NET MVC to write the information directly to the page where textcolor== background color, or anything else you may recommend.
I'd like a solution that I can use in production (where the MVC route debugger is disabled)
You can access the controller and action directly through the ViewContext.
// ASP.Net MVC 3
ViewContext.Controller.ValueProvider.GetValue("controller").RawValue
ViewContext.Controller.ValueProvider.GetValue("action").RawValue
// ASP.Net MVC 2 and below:
ViewContext.Controller.ValueProvider["controller"].RawValue
ViewContext.Controller.ValueProvider["action"].RawValue
To get the view, have a look at this answer to a similar question by Phil Haack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With