/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { // Trim blank characters string rawSmallDeviceURL = SmallDeviceRedirectionURL.Trim(); string rawLargeDeviceURL = LargeDeviceRedirectionURL.Trim(); // Get redirect cookie string redirected = CookieHelper.GetValue(CookieName.MobileRedirected); if ((AlwaysRedirect || String.IsNullOrEmpty(redirected)) && PortalContext.ViewMode.IsLiveSite()) { string redirectUrl = null; // Get user agent name or user agent string string userAgent = BrowserHelper.GetUserAgent(); if (!string.IsNullOrEmpty(userAgent)) { UserAgentEnum userAgentEnum = GetUserAgentName(userAgent); if (userAgentEnum != UserAgentEnum.Unknown) { redirectUrl = GetRedirectUrl(userAgent, userAgentEnum, rawSmallDeviceURL, rawLargeDeviceURL); } else { redirectUrl = CheckUsersRedirection(userAgent, rawSmallDeviceURL, rawLargeDeviceURL); } // Check if some address is specified if (!string.IsNullOrEmpty(redirectUrl)) { string newURL = URLHelper.ResolveUrl(redirectUrl); newURL = EnsureQueryValues(newURL); // If current URL is same as set, no redirection is done if ((!RequestContext.CurrentURL.EqualsCSafe(newURL, true)) && (!URLHelper.GetAbsoluteUrl(RequestContext.CurrentURL).EqualsCSafe(newURL, true))) { // Set redirected cookie CookieHelper.SetValue(CookieName.MobileRedirected, "true", DateTimeHelper.ZERO_TIME); URLHelper.ResponseRedirect(newURL); } } } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { // Trim blank characters string rawSmallDeviceURL = SmallDeviceRedirectionURL.Trim(); string rawLargeDeviceURL = LargeDeviceRedirectionURL.Trim(); // Get redirect cookie string redirected = CookieHelper.GetValue("CMSMobileRedirected"); if ((AlwaysRedirect || String.IsNullOrEmpty(redirected)) && (CMSContext.ViewMode == ViewModeEnum.LiveSite)) { string redirectUrl = null; // Get user agent name or user agent string string userAgent = BrowserHelper.GetUserAgent(); if (!string.IsNullOrEmpty(userAgent)) { UserAgentEnum userAgentEnum = GetUserAgentName(userAgent); string redirectSettings = null; switch (userAgentEnum) { case UserAgentEnum.BlackBerry: redirectSettings = RedirectBlackBerry; break; case UserAgentEnum.IPhone: redirectSettings = RedirectIPhone; break; case UserAgentEnum.IPad: redirectSettings = RedirectIPad; break; case UserAgentEnum.Nokia: redirectSettings = RedirectNokia; break; case UserAgentEnum.Android: redirectSettings = RedirectAndroid; break; } if (redirectSettings != null) { redirectUrl = GetRedirectUrl(redirectSettings, userAgent, userAgentEnum, rawSmallDeviceURL, rawLargeDeviceURL); } else { redirectUrl = CheckUsersRedirection(userAgent, rawSmallDeviceURL, rawLargeDeviceURL); } } // Check if some address is specified if (!string.IsNullOrEmpty(redirectUrl)) { string newURL = URLHelper.ResolveUrl(redirectUrl); // If current URL is same as set, no redirection is done if ((URLHelper.CurrentURL != newURL) && (URLHelper.GetAbsoluteUrl(URLHelper.CurrentURL) != newURL)) { // Set redirected cookie CookieHelper.SetValue("CMSMobileRedirected", "true", DateTimeHelper.ZERO_TIME); URLHelper.ResponseRedirect(newURL); } } } } }