You can use an alternative way and handle dynamically.
Create One helper class add following method inside
public static class HtmlExtension
{
public static string IsActive(this IHtmlHelper html, string controller = null, string action = null, string cssClass = null)
{
if (String.IsNullOrEmpty(cssClass))
cssClass = "active";
string currentAction = (string)html.ViewContext.RouteData.Values["action"];
string currentController = (string)html.ViewContext.RouteData.Values["controller"];
if (String.IsNullOrEmpty(controller))
controller = currentController;
if (String.IsNullOrEmpty(action))
action = currentAction;
return controller.ToLower().Split(',').Contains(currentController.ToLower()) && action.ToLower().Split(',').Contains(currentAction.ToLower()) ?
cssClass : String.Empty;
}
}
In cshtml, you need to change
<ul class="sidebar-menu tree" data-widget="tree">
<ul id="nav" class="sf-menu">
<li class="@Html.IsActive("GameVideos", "Index")"><a href="@Url.Action("Index", "GameVideos")">videogame</a></li>
<li class="@Html.IsActive("SystemRequirements", "Index")"><a href="@Url.Action("Index", "SystemRequirements")">systemReq</a></li>
<li class="@Html.IsActive("Games", "UpcommingGames,Details”)”><a href="@Url.Action("UpcommingGames”, "Games")">upcomming game</a></li>
</ul>
</nav>
Register your helper in web.config for global access.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="YourNameSpace"/> // here you need to add your htmlextension namespace
</namespaces>
</pages>
</system.web.webPages.razor>
if you want you can access specific cshtml page
@using YourNameSpace // here you need to add your HTML extension namespace