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?
The Area name is not in the RouteData.Values
but you can get it from the DataTokens collection::
ViewContext.RouteData.DataTokens["area"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With