Search code examples
c#asp.net-mvcasp.net-mvc-viewmodel

Get current action in mvc view model


I have a view model that is shared between several actions. Is it possible to get the name of the action that is being called and, if so, how do I achieve that. I need the name of the action inside a custom validator function.


Solution

  • You can add a property in your viewmodel that contains what it is used for. You can set this in the controller.