So here goes another MVC question from a noob:
This is my controller Index code:
public ActionResult Index()
{
HELPer.sessionVars sVars = new HELPer.sessionVars
{
UnboundFY = "0",
UnboundCat = "0",
UnboundFYbetween = "",
UnboundCHelp = "",
UnboundN = "",
UnboundStrUser = "",
UnboundForm = "",
UnboundPer = "",
strID = "",
UnboundStrUserDataWHERE = "",
UnboundNClass = "",
UnboundstrSQL = "",
strUser = "",
strTname = "",
theType = "",
userCategory = "",
AdminMode = false,
AddPresenter = false,
Mylasses = false,
Newnt = false,
Beduled = false,
EvalMode = false,
cat = false,
SCHEDULE = false,
Travelicy = false
};
Session["sessionVars"] = sVars;
return getMainData();
}
And this is my Model that code above is calling:
namespace ETTData.Models
{
public class HELPer
{
public class sessionVars
{
public string UnboundFY { get; set; }
public string UnboundCat { get; set; }
public string UnboundFYbetween { get; set; }
public string UnboundCHelp { get; set; }
public string UnboundN { get; set; }
public string UnboundStrUser { get; set; }
public string UnboundForm { get; set; }
public string UnboundPer { get; set; }
public string strID { get; set; }
public string UnboundStrUserDataWHERE { get; set; }
public string UnboundNClass { get; set; }
public string UnboundstrSQL { get; set; }
public string strUser { get; set; }
public string strTname { get; set; }
public string theType { get; set; }
public string userCategory { get; set; }
public bool AdminMode { get; set; }
public bool AddPresenter { get; set; }
public bool Mylasses { get; set; }
public bool Newt { get; set; }
public bool Beduled { get; set; }
public bool EvalMode { get; set; }
public bool cat { get; set; }
public bool SCHEDULE { get; set; }
public bool Travelicy { get; set; }
}
}
}
So once the view is loaded I check to make sure sessionVars has values and it does.
Now that's all great but what I really need to do is access one of those object values from the Razor view page.
As an example I have tried the following:
@Session["sessionVars"].AdminMode;
@model ETTData.Models.HELPer.sessionVars;
@Session["sessionVars"].AdminMode.toString();
@Session["sessionVars"]["AdminMode"];
@Session["sessionVars"].toString();
System.Web.HttpContext.Current.Session["sessionVars"] = sVars; //(in controller)
@Session["sessionVars"].AdminMode; //In Razor View page
All examples above failed for one reason or another.
So what am I doing incorrectly?
Update 1