88using GeneXus . Configuration ;
99using GeneXus . Utils ;
1010using Microsoft . AspNetCore . Http ;
11- using Microsoft . Azure . Functions . Worker . Http ;
1211using StackExchange . Redis ;
1312
1413namespace GeneXus . Deploy . AzureFunctions . HttpHandler
@@ -17,12 +16,19 @@ public class GXHttpAzureContext
1716 {
1817 private ICacheService2 _redis ;
1918 private string sessionId ;
20- private ISession session ;
2119 private static readonly IGXLogger log = GXLoggerFactory . GetLogger < GXHttpAzureContext > ( ) ;
2220 internal const string AZURE_SESSIONID = "GX_AZURE_SESSIONID" ;
2321
24- public ISession Session => session ;
25-
22+ public ISession Session
23+ {
24+ get
25+ {
26+ if ( ( _redis != null ) & ( sessionId != null ) )
27+ return new RedisHttpSession ( _redis , sessionId ) ;
28+ else return new MockHttpSession ( ) ;
29+ }
30+ }
31+
2632 public GXHttpAzureContext ( HttpRequest request , HttpResponse response , ICacheService2 redis )
2733 {
2834 bool isSecure = IsSecureConnection ( request ) ;
@@ -35,17 +41,12 @@ public GXHttpAzureContext( HttpRequest request, HttpResponse response, ICacheSer
3541
3642 if ( string . IsNullOrEmpty ( sessionId ) && request != null )
3743 CreateSessionId ( isSecure , response , request ) ;
38-
39- if ( ( _redis != null ) && ( sessionId != null ) )
40- session = new RedisHttpSession ( _redis , sessionId ) ;
41- else
42- session = new MockHttpSession ( ) ;
4344
4445 if ( ! string . IsNullOrEmpty ( sessionId ) )
4546 { //Refresh the session timestamp
46- if ( session is RedisHttpSession )
47+ if ( Session is RedisHttpSession )
4748 {
48- RedisHttpSession redisHttpSession = ( RedisHttpSession ) session ;
49+ RedisHttpSession redisHttpSession = ( RedisHttpSession ) Session ;
4950 //Check if session is in cache
5051 if ( redisHttpSession . SessionKeyExists ( sessionId ) )
5152 {
@@ -55,7 +56,6 @@ public GXHttpAzureContext( HttpRequest request, HttpResponse response, ICacheSer
5556 }
5657 }
5758 }
58-
5959 }
6060 private bool GetSecureConnection ( string headerKey , string headerValue )
6161 {
0 commit comments