I can get the current controller name and action name in a _Layout.cshtml
by doing the following
var controller = ViewContext.RouteData.Values["controller"].ToString();
var action = ViewContext.RouteData.Values["action"].ToString();
However when I try get the area
var area = ViewContext.RouteData.Values["area"].ToString();
it doesn't work as only 2 keys exist in that object("controller" and "action")
I examined the ViewContext.RouteData
object and cannot get a value for the current Area name.
The previous answers for the previous version of ASP.net
don't work for me.