Use this.RouteData.Values(“action”) and this.RouteData.Values(“controller”) for getting name of current controller and action in MVC instead of going through the ValueProvider. The RouteData contains information on the request / route (including controller and action), and the value provider contains information used for binding.
string controllername = this.ValueProvider.GetValue("controller").RawValue.ToString(); string actionname = this.ValueProvider.GetValue("action").RawValue.ToString();