Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Area name in Views on render time at ASP.NET MVC3 Razor

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?

like image 749
Saeid Avatar asked Mar 13 '12 10:03

Saeid


1 Answers

The Area name is not in the RouteData.Values but you can get it from the DataTokens collection::

ViewContext.RouteData.DataTokens["area"]
like image 137
nemesv Avatar answered Sep 27 '22 20:09

nemesv