title: Get controller name in asp.net mvc
body: <p>In my app I am creating a dynamic menu. The menu is populated depending upon the controller it is called for. For example in one of my Controller name is Organization. To populate the menu for it I call this</p>
  
  <pre><code>@Html.Action("Menu","Site", new { calledForController = "Organization", oId = @Model.Id })
  </code></pre>
  
  <p>Everything is working nice and smooth but the issue I am experiencing as I am having more views is that I have to put the above line in every view. What I am looking for is a way to get the current controller and action name from the route data so that I don't have to call this on every view.</p>
  
  <p>The ideal solution would be to write something like this </p>
  
  <pre><code>@Html.Action("Menu","Site")
  </code></pre>
  
  <p>in my _Layout.cshtml and then in the menu controller populate menu list depending upon where it was called from. </p>
  
  <p>If I write</p>
  
  <pre><code>this.ControllerContext.RouteData.Values["controller"].ToString();
  </code></pre>
  
  <p>in my Menu action of Site controller I am always getting Site as my controller name. Any thoughts on this? </p>