ViewContext.RouteData.Values["action"] is null on server... works fine on local machine
- by rksprst
I'm having a weird issue where ViewContext.RouteData.Values["action"] is null on my staging server, but works fine on my dev machine (asp.net development server).
The code is simple:
public string CheckActiveClass(string actionName)
{
string text = "";
if (ViewContext.RouteData.Values["action"].ToString() == actionName)
{
text = "selected";
}
return text;
}
I get the error on the ViewContext.RouteData.Values["action"] line. The error is:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Any help is appreciated. Thanks in advance.