I am using the following code to get the current “action” in my view because I want to custom build an actionlink based on it.
ViewContext.RequestContext.RouteData.Values("action")
My end goal is to build some action links with Javascript, and the .js needs to know what the current controller and action is since I’d like it to be flexible. I found the above by browsing through the framework but I don’t know if I’ve found the correct thing.
i.e.
var routeData = ViewContext.RequestContext.RouteData;
var linkStub = '/@routeData.Values("controller")/@routeData.Values("action")';
Does anyone know if this is the easiest/most straightforward way to do this?
cleanest way would be an extension method