public static MobiContext GetCurrent(HttpContext httpContext) { lock (httpContext.Request) { MobiContext mobiContext = httpContext.Items[MobiHttpContextItemKey] as MobiContext; if (mobiContext != null) { return(mobiContext as MobiContext); } mobiContext = new MobiContext(httpContext, StatisticsApplication.GetRuntime(httpContext)); httpContext.Items[MobiHttpContextItemKey] = mobiContext; return(mobiContext); } }
protected virtual void Application_PreRequestHandlerExecute(object sender, EventArgs e) { //IPaywallRuntime runtime = PaywallHttpApplication.GetRuntime(this); HttpContext httpContext = HttpContext.Current; if (HttpContext.Current.Session == null) { return; } //if (HttpContext.Current.Handler == null || HttpContext.Current.Session == null || // HttpContext.Current.Handler.GetType().IsAssignableFrom(typeof(IRequiresSessionState))) // return; MobiContext mobiContext = MobiContext.Current; return; }
// TODO: Localization public static string AppendSessionID(string url) { MobiContext mobiContext = Current; string sessionID = mobiContext.Session.SessionData.Guid.ToString().Replace("-", ""); string sessionPath = MobiChat.Constants.SessionID + "/" + sessionID; if (url.Contains(MobiChat.Constants.SessionID + "/")) { if (url.Contains(sessionPath)) { //INFO: Session in URL matches session in context. //Log.Debug(new LogMessageBuilder(new PaywallLogErrorCode("web.core", "urlhelper", "match"), // string.Format("SessionID in URL ({0}) matches SessionID ({1}) from context.", url, sessionID))); return(url); } else { //INFO: Session in URL does NOT match session in context. //Log.Debug(new LogMessageBuilder(new PaywallLogErrorCode("web.core", "urlhelper", "match"), // string.Format("SessionID in URL ({0}) does NOT match SessionID ({1}) from context.", url, sessionID))); return("/"); } } else { //INFO: Session is not provided in URL. So append it. //Log.Debug(new LogMessageBuilder(new PaywallLogErrorCode("web.core", "urlhelper", "notprovided"), // string.Format("SessionID is not provided in URL ({0}). SessionID ({1}) from context will be appended to URL.", url, sessionID))); url = PrepareUrl(url, sessionPath); } if (!url.StartsWith("/")) { url = "/" + url; } //Log.Debug(new LogMessageBuilder(new PaywallLogErrorCode("web.core", "urlhelper", "end"), // string.Format("Final URL ({0})", url))); return(url); }