#18793: Making session utilization an opt-in/opt-out feature

Work Item: 18793

--HG--
branch : 1.x
This commit is contained in:
Piotr Szmyd
2012-10-12 17:37:53 -07:00
parent 31d0a9dc38
commit cca88356d4
11 changed files with 94 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
Name: Themes
AntiForgery: enabled
SessionState: required
Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.5

View File

@@ -12,16 +12,22 @@ namespace Orchard.Themes.Preview {
public string GetPreviewTheme() {
var httpContext = _httpContextAccessor.Current();
return Convert.ToString(httpContext.Session[PreviewThemeKey]);
if (httpContext.Session != null) {
return Convert.ToString(httpContext.Session[PreviewThemeKey]);
}
return null;
}
public void SetPreviewTheme(string themeName) {
var httpContext = _httpContextAccessor.Current();
if (string.IsNullOrEmpty(themeName)) {
httpContext.Session.Remove(PreviewThemeKey);
}
else {
httpContext.Session[PreviewThemeKey] = themeName;
if (httpContext.Session != null) {
if (string.IsNullOrEmpty(themeName)) {
httpContext.Session.Remove(PreviewThemeKey);
}
else {
httpContext.Session[PreviewThemeKey] = themeName;
}
}
}
}