public void OnBeginRequest(object s, EventArgs e) { var app = (HttpApplication)s; var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); //First check if we are upgrading/installing if (app.Request.Url.LocalPath.ToLower().EndsWith("install.aspx") || app.Request.Url.LocalPath.ToLower().Contains("upgradewizard.aspx") || app.Request.Url.LocalPath.ToLower().Contains("installwizard.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith("captcha.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith("scriptresource.axd") || app.Request.Url.LocalPath.ToLower().EndsWith("webresource.axd") || app.Request.Url.LocalPath.ToLower().EndsWith("sitemap.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith(".asmx") || app.Request.Url.LocalPath.ToLower().EndsWith(".ashx") || app.Request.Url.LocalPath.ToLower().EndsWith(".svc") || app.Request.HttpMethod == "POST" || ServicesModule.ServiceApi.IsMatch(app.Context.Request.RawUrl) || IsSpecialPage(app.Request.RawUrl) || (portalSettings != null && !IsRedirectAllowed(app.Request.RawUrl, app, portalSettings))) { return; } if (_redirectionController != null) { if (portalSettings != null && portalSettings.ActiveTab != null) { if (app != null && app.Request != null && !string.IsNullOrEmpty(app.Request.UserAgent)) { //Check if redirection has been disabled for the session //This method inspects cookie and query string. It can also setup / clear cookies. if (!_redirectionController.IsRedirectAllowedForTheSession(app)) { return; } string redirectUrl = _redirectionController.GetRedirectUrl(app.Request.UserAgent); if (!string.IsNullOrEmpty(redirectUrl)) { //append thr query string from original url var queryString = app.Request.RawUrl.Contains("?") ? app.Request.RawUrl.Substring(app.Request.RawUrl.IndexOf("?") + 1) : string.Empty; if (!string.IsNullOrEmpty(queryString)) { redirectUrl = string.Format("{0}{1}{2}", redirectUrl, redirectUrl.Contains("?") ? "&" : "?", queryString); } app.Response.Redirect(redirectUrl); } } } } }
public void OnBeginRequest(object s, EventArgs e) { var app = (HttpApplication)s; //First check if we are upgrading/installing if (app.Request.Url.LocalPath.ToLower().EndsWith("install.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith("upgradewizard.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith("installwizard.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith("captcha.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith("scriptresource.axd") || app.Request.Url.LocalPath.ToLower().EndsWith("webresource.axd") || app.Request.Url.LocalPath.ToLower().EndsWith("sitemap.aspx") || app.Request.Url.LocalPath.ToLower().EndsWith(".asmx") || app.Request.Url.LocalPath.ToLower().EndsWith(".ashx") || app.Request.Url.LocalPath.ToLower().EndsWith(".svc")) { return; } if (_redirectionController != null) { var portalSettings = PortalController.GetCurrentPortalSettings(); if (portalSettings != null && portalSettings.ActiveTab != null) { if (app != null && app.Request != null && !string.IsNullOrEmpty(app.Request.UserAgent)) { //Check if redirection has been disabled for the session //This method inspects cookie and query string. It can also setup / clear cookies. if (!_redirectionController.IsRedirectAllowedForTheSession(app)) { return; } string redirectUrl = _redirectionController.GetRedirectUrl(app.Request.UserAgent); if (!string.IsNullOrEmpty(redirectUrl)) { app.Response.Redirect(redirectUrl); } } } } }
public void OnBeginRequest(object s, EventArgs e) { var app = (HttpApplication)s; var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); //First check if we are upgrading/installing var rawUrl = app.Request.RawUrl; if (!Initialize.ProcessHttpModule(app.Request, false, false) || app.Request.HttpMethod == "POST" || ServicesModule.ServiceApi.IsMatch(rawUrl) || MvcServicePath.IsMatch(rawUrl) || IsSpecialPage(rawUrl) || (portalSettings != null && !IsRedirectAllowed(rawUrl, app, portalSettings))) { return; } //Check if redirection has been disabled for the session //This method inspects cookie and query string. It can also setup / clear cookies. if (_redirectionController != null && portalSettings?.ActiveTab != null && !string.IsNullOrEmpty(app.Request.UserAgent) && _redirectionController.IsRedirectAllowedForTheSession(app)) { var redirectUrl = _redirectionController.GetRedirectUrl(app.Request.UserAgent); if (!string.IsNullOrEmpty(redirectUrl)) { //append the query string from original url var idx = rawUrl.IndexOf("?", StringComparison.Ordinal); var queryString = idx >= 0 ? rawUrl.Substring(idx + 1) : string.Empty; if (!string.IsNullOrEmpty(queryString)) { redirectUrl = string.Concat(redirectUrl, redirectUrl.Contains("?") ? "&" : "?", queryString); } app.Response.Redirect(redirectUrl); } } }