Get ControllerName and ActionName and populate the ViewData in Master Page?

前端 未结 4 1439
离开以前
离开以前 2021-01-01 09:24

I\'ve a SuperController which will be inherited from all the controllers. In the constructor I\'m trying to populate the ViewData using the ControllerN

4条回答
  •  天命终不由人
    2021-01-01 10:04

    I needed to get at these alot from views, and I hit it from a slightly different angle--I wrote a few extension methods to HtmlHelper to give the current ControllerName and ActionName. A bit easier to handle as you don't need to worry about diving into the ViewData[] bag or injecting stuff at appropriate places.

提交回复
热议问题