Search code examples
asp.net-mvc-2controllercontext

Get Current Controller name from outside a view and controller


I have tried using the ControllerContext object, but I don't know how to instantiate it. I'd like to remind you that I'm trying to get the controller name in a custom class outside a view or a controller. Thanks,


Solution

  • Don't do this. Simply pass the controller name as parameter from within the controller to whatever class needs it. Current controller is a notion that doesn't make sense from outside of a controller.