Reputation: 13592
I use ViewContext.RouteData.Values["Controller"]
to get controller name or ViewContext.RouteData.Values["action"]
to get action name in views(actually in _Layout), but for area this ViewContext.RouteData.Values["Area"]
not worked. What is your suggestion to get area name in views programmaticaly?
Upvotes: 7
Views: 2941
Reputation: 139778
The Area name is not in the RouteData.Values
but you can get it from the DataTokens collection::
ViewContext.RouteData.DataTokens["area"]
Upvotes: 17