protected void Page_Load(object sender, EventArgs e) { Ajax.Utility.RegisterTypeForAjax(typeof(Shared_Story)); //code for YT MObile redirections string redirctMobileUrl = string.Empty; MiscellaneousController objMisc = new MiscellaneousController(); if (!IsPostBack) { DeviceManager deviceManager = new DeviceManager { UserAgent = Request.UserAgent, IsMobileBrowser = Request.Browser.IsMobileDevice }; // Added by Varun Goel for NoRedirection functionality on 28 Jan 2013 TributesPortal.Utilities.StateManager stateManager = StateManager.Instance; objSessionValue = (SessionValue)stateManager.Get("objSessionvalue", StateManager.State.Session); // Validate if Session value for NoRedirection is set if (deviceManager.IsMobileDevice() && (objSessionValue == null || objSessionValue.NoRedirection == null || objSessionValue.NoRedirection == false)) { #region MObile Redirect Tributes obTrb = new Tributes(); string mTrbUrl = string.Empty; string mTrbType = string.Empty; string strStartUrl = string.Empty; int mTabId = 0; if (Request.QueryString["TributeUrl"] != null) { obTrb.TributeUrl = mTrbUrl = Request.QueryString["TributeUrl"].ToString(); } if (Request.QueryString["TributeType"] != null) { obTrb.TypeDescription = mTrbType = Request.QueryString["TributeType"].ToString(); } if (!(string.IsNullOrEmpty(mTrbUrl)) && !(string.IsNullOrEmpty(mTrbType))) { obTrb = objMisc.GetTributeUrlOnOldTributeUrl(obTrb, WebConfig.ApplicationType.ToString()); strStartUrl = string.Format("{0}{1}{2}{3}{4}{5}", "https://www.", WebConfig.TopLevelDomain, "/mobile/index.html?tributeurl=", obTrb.TributeUrl, "&tributetype=", mTrbType); string url = Request.Url.ToString().ToLower(); #region story if (url.Contains("story.aspx")) redirctMobileUrl = strStartUrl + "&page=story"; #endregion #region notes else if (url.Contains("notes.aspx")) redirctMobileUrl = strStartUrl + "&page=notes"; #endregion #region note else if (url.Contains("notefullview.aspx")) { if ((Request.QueryString["noteId"] != null)) { if (int.TryParse(Request.QueryString["noteId"], out mTabId)) { redirctMobileUrl = strStartUrl + "&page=note&id=" + mTabId.ToString(); } else { redirctMobileUrl = strStartUrl + "&page=notes"; } } else { redirctMobileUrl = strStartUrl + "&page=notes"; } } #endregion #region events else if (url.Contains("event.aspx")) redirctMobileUrl = strStartUrl + "&page=events"; #endregion #region event else if (url.Contains("eventfullview.aspx")) { if ((Request.QueryString["EventID"] != null)) { if (int.TryParse(Request.QueryString["EventID"], out mTabId)) { redirctMobileUrl = strStartUrl + "&page=event&id=" + mTabId.ToString(); } else { redirctMobileUrl = strStartUrl + "&page=events"; } } else { redirctMobileUrl = strStartUrl + "&page=events"; } } #endregion #region guestbook else if (url.Contains("guestbook.aspx")) redirctMobileUrl = strStartUrl + "&page=guestbook"; #endregion #region gift else if (url.Contains("gift.aspx")) redirctMobileUrl = strStartUrl + "&page=memorials"; #endregion #region photogallery else if (url.Contains("photogallery.aspx")) redirctMobileUrl = strStartUrl + "&page=gallery"; #endregion #region photoalbum else if (url.Contains("photoalbum.aspx")) { if ((Request.QueryString["PhotoAlbumId"] != null)) { if (int.TryParse(Request.QueryString["PhotoAlbumId"], out mTabId)) { redirctMobileUrl = strStartUrl + "&page=photoalbum&id=" + mTabId.ToString(); } else { redirctMobileUrl = strStartUrl + "&page=gallery"; } } else { redirctMobileUrl = strStartUrl + "&page=gallery"; } } #endregion #region photoview else if (url.Contains("photoview.aspx")) { if ((Request.QueryString["PhotoId"] != null)) { if (int.TryParse(Request.QueryString["PhotoId"], out mTabId)) { redirctMobileUrl = strStartUrl + "&page=photo&id=" + mTabId.ToString(); } else { redirctMobileUrl = strStartUrl + "&page=gallery"; } } else { redirctMobileUrl = strStartUrl + "&page=gallery"; } } #endregion #region photoview else if (url.Contains("photoview.aspx")) redirctMobileUrl = strStartUrl + "&page=gallery"; #endregion #region managevideo else if (url.ToLower().Contains("managevideo.aspx")) { #region videoTribute if (url.ToLower().Contains("videotype=videotribute")) { redirctMobileUrl = string.Empty; } #endregion else if ((Request.QueryString["videoId"] != null)) { if (int.TryParse(Request.QueryString["videoId"], out mTabId)) { redirctMobileUrl = strStartUrl + "&page=video&id=" + mTabId.ToString(); } else { redirctMobileUrl = strStartUrl + "&page=gallery"; } } else { redirctMobileUrl = strStartUrl + "&page=gallery"; } } #endregion #region videos else if (url.ToLower().Contains("videogallery.aspx")) { redirctMobileUrl = strStartUrl + "&page=gallery"; } #endregion else { redirctMobileUrl = strStartUrl + "&page=home"; } } #endregion } } if (string.IsNullOrEmpty(redirctMobileUrl)) { try { PageUrl = GetRedirectUrl(); PageTitle = Page.Title.ToString(); codedURL = HttpUtility.UrlEncode(PageUrl).ToString(); codedtitle = HttpUtility.UrlEncode(PageTitle).ToString(); if (Request.QueryString["topurl"] != null) { _TopUrl = Request.QueryString["topurl"].ToString(); Response.Cookies["topurl"].Value = _TopUrl; Response.Cookies["topurl"].Domain = _TopUrl; Response.Cookies["topurl"].Expires = DateTime.Now.AddHours(4); } if (Request.Cookies["topurl"] != null) { hdnTopUrl.Value = Request.Cookies["topurl"].Value.ToString(); } if (Session["isInIframe"] != null) { isInIframe = bool.Parse(Session["isInIframe"].ToString()); } // New code added on 07 june 2011 by rupendra to handle Apple safari problem if (Request.Browser.Browser.ToString().Trim().Equals("AppleMAC-Safari")) { } //LHK:EmptyDivAboveMainPanel StateManager stateTribute = StateManager.Instance; SessionValue objSessvalue = (SessionValue)stateTribute.Get("objSessionvalue", StateManager.State.Session); if ((Request.QueryString["TributeUrl"] != null)) { string _trbUrl = Request.QueryString["TributeUrl"].ToString(); GetCustomHeaderVisible(_trbUrl, WebConfig.ApplicationType.ToString()); } if (!(objSessvalue != null)) { if (!IsCustomHeaderOn) { EmptyDivAboveMainPanel.Visible = true; } } //LHK:EmptyDivAboveMainPanel if (WebConfig.ApplicationMode.Equals("local")) { appDomian = WebConfig.AppBaseDomain.ToString(); } else { StateManager stateManager = StateManager.Instance; Tributes objTrib = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session); //Ashu 18 aug for session null if (objTrib != null) { if (objTrib.TypeDescription != null) { appDomian = "http://" + objTrib.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/"; } else if (Session["PhotoAlbumTributeSession"] != null) { objTrib = Session["PhotoAlbumTributeSession"] as Tributes; if (objTrib.TypeDescription != null) appDomian = "http://" + objTrib.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/"; } } else if (Session["PhotoAlbumTributeSession"] != null) { objTrib = Session["PhotoAlbumTributeSession"] as Tributes; if (objTrib != null) { if (objTrib.TypeDescription != null) appDomian = "http://" + objTrib.TypeDescription.ToString().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/"; } } } try { if (Request.QueryString["TributeType"] != null) { ytHeader.TributeType = Request.QueryString["TributeType"].ToString(); } // get the Tribute and User detail from the Session GetValuesFromSession(); // Set the Class of the div according the Page Name SetClass(); SetTabClass(); // This function will set the Left Menu SetMenuOptions(); SetMenuItemClass(); // This Function will load themes in the left panel and loads the selected theme for the tribute. LoadThemes(); //Method to check if tribute already in favorite list. CheckForFavorite(); //to set affiliate link. AffiliateLinks(_tributeType); StateManager objStateManager = StateManager.Instance; if (objStateManager.Get("NoteSession", StateManager.State.Session) != null) _noteId = int.Parse(objStateManager.Get("NoteSession", StateManager.State.Session).ToString()); if (objStateManager.Get("VideoSession", StateManager.State.Session) != null) _videoId = int.Parse(objStateManager.Get("VideoSession", StateManager.State.Session).ToString()); if (objStateManager.Get("PhotoViewSession", StateManager.State.Session) != null) _photoId = int.Parse(objStateManager.Get("PhotoViewSession", StateManager.State.Session).ToString()); if (objStateManager.Get("PhotoAlbumId", StateManager.State.Session) != null) _photoAlbumId = int.Parse(objStateManager.Get("PhotoAlbumId", StateManager.State.Session).ToString()); if (objStateManager.Get("XmlFilePath", StateManager.State.Session) != null) //to get xml file name for slideshow _xmlFilePath = objStateManager.Get("XmlFilePath", StateManager.State.Session).ToString(); //to get photo number from where to start slideshow. if (objStateManager.Get("SlideShowStartPhoto", StateManager.State.Session) != null) //to get start photo number in slideshow. _recordNumber = int.Parse( objStateManager.Get("SlideShowStartPhoto", StateManager.State.Session).ToString()); else _recordNumber = 0; // Set the controls value SetControlsValue(); SetPageNameInSession(_typeName); if (!(string.IsNullOrEmpty(_tributeType))) { if (_tributeType == "Anniversary") _themeName = "AnniversaryDefault"; else if (_tributeType == "Birthday") _themeName = "BirthdayDefault"; else if (_tributeType == "Graduation") _themeName = "GraduationDefault"; else if (_tributeType == "Memorial") _themeName = "MemorialDefault"; else if (_tributeType == "New Baby") _themeName = "BabyDefault"; else if (_tributeType == "Wedding") _themeName = "WeddingDefault"; } //LHK: for photo upgrade changes if ((liAdd.Visible == false) && (liEdit.Visible == false) && (liView.Visible == false) && (liDownloadalbum.Visible == false) && (liVieFullPhoto.Visible == false)) divSubTool.Visible = false; } catch (Exception ex) { LogError(ex.Message, ex.StackTrace); throw ex; } } catch (Exception ex) { LogError(ex.Message, ex.StackTrace); throw ex; } } else { Response.Redirect(redirctMobileUrl, false); } }
protected void Page_Init(object sender, EventArgs e) { //Page.RegisterStartupScript("ScriptDescription", "<script type=\"text/javascript\"> alert('" + Request.Url.ToString() + "');</script>"); try { StateManager stateManager = StateManager.Instance; MiscellaneousController objMisc = new MiscellaneousController(); //-- Ashu(June2,2011) : Changes for jquery conflict issues & Javascript exception if (!(Request.Url.AbsolutePath.ToLower().EndsWith("managephotoalbum.aspx"))) { DivScript.Visible = true; divModalboxscript.Visible = true; } else { DivScript.Visible = false; divModalboxscript.Visible = false; } app_domin = WebConfig.AppBaseDomain; // to avoid redirection for create photo album page if (!(Request.Url.AbsolutePath.ToLower().EndsWith("managephotoalbum.aspx"))) { //if Tribute Type and Tribute Url are in querystring #region LHK:Redirection to upgradedUrl if (!this.IsPostBack) { Tributes objTrb = new Tributes(); //GetUpgradedUrl if ((Request.QueryString["TributeUrl"] != null)) { _tributeUrl = Request.QueryString["TributeUrl"].ToString(); objTrb.TributeUrl = _tributeUrl = Request.QueryString["TributeUrl"].ToString(); if (Request.QueryString["TributeType"] != null) { objTrb.TypeDescription = Request.QueryString["TributeType"].ToString(); } else if (Session["PhotoAlbumTributeSession"] != null) { objTrb = Session["PhotoAlbumTributeSession"] as Tributes; if (objTrb != null) if (string.IsNullOrEmpty(objTrb.TypeDescription)) Session["TributeType"] = objTrb.TypeDescription; } objTrb = objMisc.GetTributeUrlOnOldTributeUrl(objTrb, WebConfig.ApplicationType.ToString()); if (Request.QueryString["TributeType"] != null) { objTrb.TypeDescription = Request.QueryString["TributeType"].ToString(); } if (objTrb != null) { if (objTrb.TributeUrl != null) { if (!(string.IsNullOrEmpty(objTrb.TributeUrl.ToString())) && (!(_tributeUrl.Equals(objTrb.TributeUrl.ToString())))) { url = GetRedirectUrl(); Response.Redirect(url, true); } } } } } #endregion #region For Image uploader redirection //LHK: redirection from main domain to subdomain- for image uploader if (!(WebConfig.ApplicationMode.Equals("local"))) { if (Request.QueryString["Type"] != null && Request.QueryString["TributeUrl"] != null) { RediectUsingQueryString(); } else { RedirectUsingSession(); } } if (WebConfig.ApplicationMode.Equals("local")) { if (Request.QueryString["mode"] != null && Request.QueryString["TributeUrl"] != null) { if (Request.QueryString["mode"].ToString() == "Create") { if (FacebookWebContext.Current.Session != null) { url = WebConfig.AppBaseDomain + Request.QueryString["TributeUrl"].ToString() + "/photos.aspx?post_on_facebook=True"; } else { url = WebConfig.AppBaseDomain + Request.QueryString["TributeUrl"].ToString() + "/photos.aspx"; } } else if (Request.QueryString["mode"].ToString() == "AddPhotos") { url = WebConfig.AppBaseDomain + Request.QueryString["TributeUrl"].ToString() + "/photoalbum.aspx?photoAlbumId=" + Request.QueryString["AlbumId"].ToString(); } if (!string.IsNullOrEmpty(url)) Response.Redirect(url, false); } } #endregion } Tributes objTribute = new Tributes(); if ((Request.QueryString["TributeUrl"] != null) && (Request.QueryString["TributeType"] != null)) { objTribute.TributeUrl = Request.QueryString["TributeUrl"].ToString(); objTribute.TypeDescription = Request.QueryString["TributeType"].ToString(); stateManager.Add("TributeSession", objMisc.GetTributeSessionForUrlAndType(objTribute, WebConfig.ApplicationType.ToString()), TributesPortal.Utilities.StateManager.State.Session); } else if (Request.QueryString["TributeUrl"] != null) { objTribute.TributeUrl = Request.QueryString["TributeUrl"].ToString(); if (Session["TributeType"] != null) objTribute.TypeDescription = Session["TributeType"].ToString(); else objTribute.TypeDescription = null; stateManager.Add("TributeSession", objMisc.GetTributeSessionForUrlAndType(objTribute, WebConfig.ApplicationType.ToString()), TributesPortal.Utilities.StateManager.State.Session); } Tributes objTrib = (Tributes)stateManager.Get("TributeSession", StateManager.State.Session); if (objTrib != null) { if (objTrib.CreatedDate != null) Session["TributeCreatedDate"] = objTrib.CreatedDate; if (objTrib.TributeUrl != null) Session["TributeURL"] = objTrib.TributeUrl; } TributePackage objpackage = new TributePackage(); objpackage.UserTributeId = objTribute.TributeId; object[] param = { objpackage }; objMisc.TriputePackageInfo(param); if (objpackage.CustomError == null) { _packageId = objpackage.PackageId; if (_packageId != 1 && objpackage.EndDate != null) { _endDate = (DateTime)objpackage.EndDate; Session["tributeEndDate"] = _endDate; } } } catch (Exception ex) { throw ex; } }