public static string GetProductDetails() { // HttpContext is used here to access non static variable Session inside static method. DataTable dtProductDetails = new DataTable(); decimal client_alias = Convert.ToDecimal(HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4)); dtProductDetails = VPCRMSBAL.GetProductAssignment(); String json = DataTableToJSONWithJavaScriptSerializer(dtProductDetails); return(json); }