I use the session wrapper as follows:
public interface ISessionWrapper
{
CultureInfo Culture { get; set; }
}
public class SessionWrapper: ISessionWrapper
{
private T GetFromSession<T>(string key)
{
return (T)HttpContext.Current.Session[key];
}
private void SetInSession(string key, object value)
{
HttpContext.Current.Session[key] = value;
}
public CultureInfo Culture
{
get { return GetFromSession<CultureInfo>("Culture"); }
set { SetInSession("Culture", value); }
}
}
I can use this interface in my controller as follows:
private readonly ISessionWrapper sessionWrapper = new SessionWrapper();
ci = new CultureInfo(langName);
sessionWrapper.Culture = ci;
But how can I access this shell in the view below to replace the session variable (direct call)?
@switch (Session["Culture"].ToString())
{
case "fr":
case "uk":
}
source
share