diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs index 4e96912f3..753864931 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs @@ -1684,9 +1684,9 @@ public string RemoveInternalParms(string query) query = RemoveInternalSuffixes(query); return query; } - internal static string RemoveInternalSuffixes(string query) + internal static string RemoveInternalSuffix(string query, string param) { - int idx = query.IndexOf(GXNavigationHelper.POPUP_LEVEL); + int idx = query.IndexOf(param); if (idx == 1) return ""; if (idx > 1) @@ -1699,6 +1699,12 @@ internal static string RemoveInternalSuffixes(string query) } return query; } + + internal static string RemoveInternalSuffixes(string query) + { + query = RemoveInternalSuffix(query, GXNavigationHelper.POPUP_LEVEL); + return RemoveInternalSuffix(query, GXNavigationHelper.TAB_ID); + } private string RemoveEventPrefix(string query) { if (IsGxAjaxRequest() || isAjaxEventMode()) diff --git a/dotnet/src/dotnetframework/GxClasses/Core/Web/GxHttpServer.cs b/dotnet/src/dotnetframework/GxClasses/Core/Web/GxHttpServer.cs index f834c38b4..424700a73 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/Web/GxHttpServer.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/Web/GxHttpServer.cs @@ -189,7 +189,8 @@ public class GxHttpRequest { HttpRequest _httpReq; IGxContext _context; - string _referrer = ""; + string _referrer = string.Empty; + string _tabId = string.Empty; public GxHttpRequest(IGxContext context) { @@ -213,7 +214,7 @@ public string Method get { if (_httpReq == null) - return ""; + return string.Empty; return _httpReq.GetMethod(); } } @@ -223,14 +224,14 @@ public short ErrCode } public string ErrDescription { - get {return "";} + get {return string.Empty; } } public string BaseURL { get { if (_httpReq == null) - return ""; + return string.Empty; #if NETCORE string baseURL = _httpReq.GetDisplayUrl(); #else @@ -246,7 +247,7 @@ public string QueryString get { if (_httpReq == null) - return ""; + return string.Empty; string urlQuery; #if NETCORE urlQuery = _httpReq.QueryString.HasValue ? _httpReq.QueryString.Value : string.Empty; @@ -258,7 +259,7 @@ public string QueryString string url = (_context != null && _context.isAjaxRequest()) ? ((GxContext)_context).RemoveInternalParms(urlQuery) : urlQuery.Substring(1, urlQuery.Length - 1); - return url.Replace("?",""); + return url.Replace("?", string.Empty); } } public string ServerHost @@ -266,7 +267,7 @@ public string ServerHost get { if (_httpReq == null) - return ""; + return string.Empty; return _context.GetServerName(); } } @@ -293,7 +294,7 @@ public string ScriptPath get { if (_httpReq == null) - return ""; + return string.Empty; return _httpReq.GetApplicationPath()+"/"; } } @@ -302,7 +303,7 @@ public string ScriptName get { if (_httpReq == null) - return ""; + return string.Empty; string virtualPath = _httpReq.GetFilePath(); return virtualPath.Remove(0, virtualPath.LastIndexOf('/')+1) ; } @@ -322,10 +323,39 @@ public string Referrer } catch { - return ""; + return string.Empty; } } } + + public string TabId + { + get + { + if (_httpReq == null) + return string.Empty; + + string sUrl = string.Empty; + +#if NETCORE + sUrl = _httpReq.GetDisplayUrl(); +#else + sUrl = _httpReq.Url.ToString(); +#endif + + if (string.IsNullOrEmpty(_tabId)) + { + _tabId = GXNavigationHelper.getUrlComponent(sUrl, GXNavigationHelper.TAB_ID); + } + if (string.IsNullOrEmpty(_tabId)) + { + _tabId = GetHeader(GXNavigationHelper.TAB_ID_HEADER); + + } + return _tabId; + } + } + public string RemoteAddress { get @@ -360,10 +390,10 @@ public string[] GetVariables() public string GetHeader( string name) { if (_httpReq == null) - return ""; + return string.Empty; string hdr = _httpReq.Headers[name]; if (hdr == null) - return ""; + return string.Empty; return hdr; } public string GetValue( string name) diff --git a/dotnet/src/dotnetframework/GxClasses/Helpers/GXNavigationHelper.cs b/dotnet/src/dotnetframework/GxClasses/Helpers/GXNavigationHelper.cs index 218180e38..3c82412e0 100644 --- a/dotnet/src/dotnetframework/GxClasses/Helpers/GXNavigationHelper.cs +++ b/dotnet/src/dotnetframework/GxClasses/Helpers/GXNavigationHelper.cs @@ -9,6 +9,8 @@ namespace GeneXus.Application public class GXNavigationHelper { public static string POPUP_LEVEL = "gxPopupLevel"; + public static string TAB_ID = "gxTabId"; + public static string TAB_ID_HEADER = "X-Gx-Tabid"; public static string CALLED_AS_POPUP = "gxCalledAsPopup"; [System.Diagnostics.CodeAnalysis.SuppressMessage("GxFxCopRules", "CR1000:EnforceThreadSafeType")] @@ -122,43 +124,58 @@ public int Count() return referers.Count; } - public int GetUrlPopupLevel(string url) + internal static string getUrlComponent(string url, string key) { + Uri uri = null; + string result = ""; + try { - Uri uri = null; - try - { - uri = new Uri(url); - } - catch { } - if (uri != null) - { - url = uri.GetComponents(UriComponents.Query, UriFormat.Unescaped); - } - int popupLevel = -1; - if (url != null) + uri = new Uri(url); + } + catch { } + if (uri != null) + { + url = uri.GetComponents(UriComponents.Query, UriFormat.Unescaped); + } + if (url != null) + { + int pIdx = url.IndexOf(key); + if (pIdx != -1) { - int pIdx = url.IndexOf(POPUP_LEVEL); - if (pIdx != -1) + int eqIdx = url.IndexOf("=", pIdx); + if (eqIdx != -1) { - int eqIdx = url.IndexOf("=", pIdx); - if (eqIdx != -1) + int cIdx = url.IndexOf(";", eqIdx); + if (cIdx > eqIdx) { - int cIdx = url.IndexOf(";", eqIdx); - if (cIdx > eqIdx) + try + { + result = url.Substring(eqIdx + 1, cIdx - eqIdx - 1); + } + catch { - try - { - string strLvl = url.Substring(eqIdx + 1, cIdx - eqIdx - 1); - popupLevel = int.Parse(strLvl); - } - catch - { - popupLevel = -1; - } } } } } + } + return result; + } + + public int GetUrlPopupLevel(string url) + { + int popupLevel = -1; + string sPopUpLvl = getUrlComponent(url, POPUP_LEVEL); + try + { + if (!String.IsNullOrEmpty(sPopUpLvl)) + { + popupLevel = int.Parse(sPopUpLvl); + } + } + catch + { + popupLevel = -1; + } return popupLevel; } }