/// ----------------------------------------------------------------------------- /// <summary> /// The Commit method commits the package installation /// </summary> /// <history> /// [cnurse] 08/01/2007 created /// </history> /// ----------------------------------------------------------------------------- public override void Commit() { for (int index = 0; index <= _componentInstallers.Count - 1; index++) { ComponentInstallerBase compInstaller = _componentInstallers.Values[index]; if (compInstaller.Version >= Package.InstalledVersion && compInstaller.Completed) { compInstaller.Commit(); } } //Add Event Message if (_eventMessage != null && !String.IsNullOrEmpty(_eventMessage.Attributes["UpgradeVersionsList"])) { _eventMessage.Attributes.Set("desktopModuleID", Null.NullInteger.ToString()); EventQueueController.SendMessage(_eventMessage, "Application_Start"); } if (Log.Valid) { Log.AddInfo(Util.INSTALL_Committed); } else { Log.AddFailure(Util.INSTALL_Aborted); } Package.InstallerInfo.PackageID = Package.PackageID; }
private static string InitializeApp(HttpApplication app, ref bool initialized) { var request = app.Request; var redirect = Null.NullString; Logger.Trace("Request " + request.Url.LocalPath); // Don't process some of the AppStart methods if we are installing if (!IsUpgradeOrInstallRequest(app.Request)) { // Check whether the current App Version is the same as the DB Version redirect = CheckVersion(app); if (string.IsNullOrEmpty(redirect) && !InstallBlocker.Instance.IsInstallInProgress()) { Logger.Info("Application Initializing"); // Set globals Globals.IISAppName = request.ServerVariables["APPL_MD_PATH"]; Globals.OperatingSystemVersion = Environment.OSVersion.Version; Globals.NETFrameworkVersion = GetNETFrameworkVersion(); Globals.DatabaseEngineVersion = GetDatabaseEngineVersion(); Upgrade.CheckFipsCompilanceAssemblies(); // Log Server information ServerController.UpdateServerActivity(new ServerInfo()); // Start Scheduler StartScheduler(); // Log Application Start LogStart(); // Process any messages in the EventQueue for the Application_Start event EventQueueController.ProcessMessages("Application_Start"); ServicesRoutingManager.RegisterServiceRoutes(); ModuleInjectionManager.RegisterInjectionFilters(); ConnectionsManager.Instance.RegisterConnections(); // Set Flag so we can determine the first Page Request after Application Start app.Context.Items.Add("FirstRequest", true); Logger.Info("Application Initialized"); initialized = true; } } else { // NET Framework version is neeed by Upgrade Globals.NETFrameworkVersion = GetNETFrameworkVersion(); Globals.IISAppName = request.ServerVariables["APPL_MD_PATH"]; Globals.OperatingSystemVersion = Environment.OSVersion.Version; } return(redirect); }
private void UpdateModuleInterfaces(string BusinessControllerClass) { //this cannot be done directly at this time because //the module may not be loaded into the app domain yet //So send an EventMessage that will process the update //after the App recycles var oAppStartMessage = new EventMessage { Sender = ModuleContext.PortalSettings.UserInfo.Username, Priority = MessagePriority.High, ExpirationDate = DateTime.Now.AddYears(-1), SentDate = DateTime.Now, Body = "", ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke", ProcessorCommand = "UpdateSupportedFeatures" }; //Add custom Attributes for this message oAppStartMessage.Attributes.Add("BusinessControllerClass", BusinessControllerClass); oAppStartMessage.Attributes.Add("DesktopModuleId", DesktopModule.DesktopModuleID.ToString()); //send it to occur on next App_Start Event EventQueueController.SendMessage(oAppStartMessage, "Application_Start"); //force an app restart Config.Touch(); }
private void UpdateModuleInterfaces(string BusinessControllerClass) { //Check to see if Interfaces (SupportedFeatures) Need to be Updated if (BusinessControllerClass != "") { //this cannot be done directly at this time because //the module may not be loaded into the app domain yet //So send an EventMessage that will process the update //after the App recycles EventMessage oAppStartMessage = new EventMessage(); oAppStartMessage.ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke"; oAppStartMessage.Attributes.Add("ProcessCommand", "UpdateSupportedFeatures"); oAppStartMessage.Attributes.Add("BusinessControllerClass", BusinessControllerClass); oAppStartMessage.Attributes.Add("DesktopModuleId", DesktopModuleId.ToString()); oAppStartMessage.Priority = MessagePriority.High; oAppStartMessage.SentDate = DateTime.Now; oAppStartMessage.Body = ""; //make it expire as soon as it's processed oAppStartMessage.ExpirationDate = DateTime.Now.AddYears(-1); //send it EventQueueController oEventQueueController = new EventQueueController(); oEventQueueController.SendMessage(oAppStartMessage, "Application_Start"); //force an app restart Config.Touch(); } }
public override void Commit() { if (!string.IsNullOrEmpty(DesktopModule.CodeSubDirectory)) { Config.AddCodeSubDirectory(DesktopModule.CodeSubDirectory); } if (DesktopModule.SupportedFeatures == Null.NullInteger) { //Set an Event Message so the features are loaded by reflection on restart EventQueue.EventMessage oAppStartMessage = new EventQueue.EventMessage(); oAppStartMessage.Priority = MessagePriority.High; oAppStartMessage.ExpirationDate = DateTime.Now.AddYears(-1); oAppStartMessage.SentDate = System.DateTime.Now; oAppStartMessage.Body = ""; oAppStartMessage.ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke"; oAppStartMessage.ProcessorCommand = "UpdateSupportedFeatures"; //Add custom Attributes for this message oAppStartMessage.Attributes.Add("BusinessControllerClass", DesktopModule.BusinessControllerClass); oAppStartMessage.Attributes.Add("desktopModuleID", DesktopModule.DesktopModuleID.ToString()); //send it to occur on next App_Start Event EventQueueController.SendMessage(oAppStartMessage, "Application_Start_FirstRequest"); } if (EventMessage != null) { EventMessage.Attributes.Set("desktopModuleID", DesktopModule.DesktopModuleID.ToString()); EventQueueController.SendMessage(EventMessage, "Application_Start"); } if (!DesktopModule.IsPremium) { DesktopModuleController.AddDesktopModuleToPortals(DesktopModule.DesktopModuleID); } }
private static string InitializeApp(HttpApplication app) { HttpServerUtility Server = app.Server; HttpRequest Request = app.Request; string redirect = Null.NullString; if (HttpContext.Current.Request.ApplicationPath == "/") { if (String.IsNullOrEmpty(Config.GetSetting("InstallationSubfolder"))) { Globals.ApplicationPath = ""; } else { Globals.ApplicationPath = (Config.GetSetting("InstallationSubfolder") + "/").ToLowerInvariant(); } } else { Globals.ApplicationPath = Request.ApplicationPath.ToLowerInvariant(); } Globals.ApplicationMapPath = System.AppDomain.CurrentDomain.BaseDirectory.Substring(0, System.AppDomain.CurrentDomain.BaseDirectory.Length - 1); Globals.ApplicationMapPath = Globals.ApplicationMapPath.Replace("/", "\\"); Globals.HostPath = Globals.ApplicationPath + "/Portals/_default/"; Globals.HostMapPath = Server.MapPath(Globals.HostPath); Globals.InstallPath = Globals.ApplicationPath + "/Install/"; Globals.InstallMapPath = Server.MapPath(Globals.InstallPath); Globals.GetStatus(); if (!Request.Url.LocalPath.ToLower().EndsWith("installwizard.aspx") && !Request.Url.LocalPath.ToLower().EndsWith("install.aspx")) { redirect = CheckVersion(app); if (string.IsNullOrEmpty(redirect)) { CacheMappedDirectory(); Globals.IISAppName = Request.ServerVariables["APPL_MD_PATH"]; Globals.OperatingSystemVersion = Environment.OSVersion.Version; Globals.NETFrameworkVersion = GetNETFrameworkVersion(); Globals.DatabaseEngineVersion = GetDatabaseEngineVersion(); Upgrade.TryUpgradeNETFramework(); StartScheduler(); LogStart(); EventQueueController.ProcessMessages("Application_Start"); //Set Flag so we can determine the first Page Request after Application Start app.Context.Items.Add("FirstRequest", true); ServerController.UpdateServerActivity(new ServerInfo()); } } else { Globals.NETFrameworkVersion = GetNETFrameworkVersion(); } return(redirect); }
private static string InitializeApp(HttpApplication app) { DnnLog.MethodEntry(); HttpRequest request = app.Request; string redirect = Null.NullString; DnnLog.Trace("Request " + request.Url.LocalPath); //Don't process some of the AppStart methods if we are installing if (!request.Url.LocalPath.ToLower().EndsWith("installwizard.aspx") && !request.Url.LocalPath.ToLower().EndsWith("upgradewizard.aspx") && !request.Url.LocalPath.ToLower().EndsWith("install.aspx")) { //Check whether the current App Version is the same as the DB Version redirect = CheckVersion(app); if (string.IsNullOrEmpty(redirect)) { DnnLog.Info("Application Initializing"); //Cache Mapped Directory(s) CacheMappedDirectory(); //Set globals Globals.IISAppName = request.ServerVariables["APPL_MD_PATH"]; Globals.OperatingSystemVersion = Environment.OSVersion.Version; Globals.NETFrameworkVersion = GetNETFrameworkVersion(); Globals.DatabaseEngineVersion = GetDatabaseEngineVersion(); //Try and Upgrade to Current Framewok Upgrade.TryUpgradeNETFramework(); //Start Scheduler StartScheduler(); //Log Application Start LogStart(); //Process any messages in the EventQueue for the Application_Start event EventQueueController.ProcessMessages("Application_Start"); ServicesRoutingManager.RegisterServiceRoutes(); //Set Flag so we can determine the first Page Request after Application Start app.Context.Items.Add("FirstRequest", true); //Log Server information ServerController.UpdateServerActivity(new ServerInfo()); DnnLog.Info("Application Initialized"); } } else { //NET Framework version is neeed by Upgrade Globals.NETFrameworkVersion = GetNETFrameworkVersion(); } return(redirect); }
protected override string UpgradeModule(DesktopModuleInfo ModuleInfo) { if (!String.IsNullOrEmpty(ModuleInfo.BusinessControllerClass)) { string UpgradeVersionsList = ""; if (UpgradeVersions.Count > 0) { foreach (string Version in UpgradeVersions) { UpgradeVersionsList = UpgradeVersionsList + Version + ","; DeleteFiles(ModuleInfo.FolderName, Version); } if (UpgradeVersionsList.EndsWith(",")) { UpgradeVersionsList = UpgradeVersionsList.Remove(UpgradeVersionsList.Length - 1, 1); } } else { UpgradeVersionsList = ModuleInfo.Version; } //this cannot be done directly at this time because //the module may not be loaded into the app domain yet //So send an EventMessage that will process the update //after the App recycles EventMessage oAppStartMessage = new EventMessage(); oAppStartMessage.ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke"; oAppStartMessage.Attributes.Add("ProcessCommand", "UpgradeModule"); oAppStartMessage.Attributes.Add("BusinessControllerClass", ModuleInfo.BusinessControllerClass); oAppStartMessage.Attributes.Add("DesktopModuleId", ModuleInfo.DesktopModuleID.ToString()); oAppStartMessage.Attributes.Add("UpgradeVersionsList", UpgradeVersionsList); oAppStartMessage.Priority = MessagePriority.High; oAppStartMessage.SentDate = DateTime.Now; //make it expire as soon as it's processed oAppStartMessage.ExpirationDate = DateTime.Now.AddYears(-1); //send it EventQueueController oEventQueueController = new EventQueueController(); oEventQueueController.SendMessage(oAppStartMessage, "Application_Start"); } //TODO: Need to implement a feedback loop to display the results of the upgrade. return(""); }
public void UpdateModuleInterfaces(ref DesktopModuleInfo desktopModuleInfo, string sender, bool forceAppRestart) { EventMessage oAppStartMessage = new EventMessage(); oAppStartMessage.Sender = sender; oAppStartMessage.Priority = MessagePriority.High; oAppStartMessage.ExpirationDate = DateTime.Now.AddYears(-1); oAppStartMessage.SentDate = System.DateTime.Now; oAppStartMessage.Body = ""; oAppStartMessage.ProcessorType = "CommonLibrary.Entities.Modules.EventMessageProcessor, CommonLibrary"; oAppStartMessage.ProcessorCommand = "UpdateSupportedFeatures"; oAppStartMessage.Attributes.Add("BusinessControllerClass", desktopModuleInfo.BusinessControllerClass); oAppStartMessage.Attributes.Add("DesktopModuleId", desktopModuleInfo.DesktopModuleID.ToString()); EventQueueController.SendMessage(oAppStartMessage, "Application_Start"); if ((forceAppRestart)) { Config.Touch(); } }
public void UpdateModuleInterfaces(ref DesktopModuleInfo desktopModuleInfo, string sender, bool forceAppRestart) { var oAppStartMessage = new EventMessage { Sender = sender, Priority = MessagePriority.High, ExpirationDate = DateTime.Now.AddYears(-1), SentDate = DateTime.Now, Body = "", ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke", ProcessorCommand = "UpdateSupportedFeatures" }; oAppStartMessage.Attributes.Add("BusinessControllerClass", desktopModuleInfo.BusinessControllerClass); oAppStartMessage.Attributes.Add("DesktopModuleId", desktopModuleInfo.DesktopModuleID.ToString()); EventQueueController.SendMessage(oAppStartMessage, "Application_Start"); if ((forceAppRestart)) { Config.Touch(); } }
/// <summary> /// Application_Start /// Executes on the first web request into the portal application, /// when a new DLL is deployed, or when web.config is modified. /// </summary> /// <remarks> /// - global variable initialization /// </remarks> protected void Application_Start(object sender, EventArgs e) { HttpServerUtility httpServerUtility = HttpContext.Current.Server; //global variable initialization Globals.ServerName = httpServerUtility.MachineName; if (HttpContext.Current.Request.ApplicationPath == "/") { Globals.ApplicationPath = ""; } else { Globals.ApplicationPath = HttpContext.Current.Request.ApplicationPath; } Globals.ApplicationMapPath = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.Length - 1); Globals.ApplicationMapPath = Globals.ApplicationMapPath.Replace("/", "\\"); Globals.HostPath = Globals.ApplicationPath + "/Portals/_default/"; Globals.HostMapPath = httpServerUtility.MapPath(Globals.HostPath); Globals.AssemblyPath = Globals.ApplicationMapPath + "\\bin\\dotnetnuke.dll"; //Check whether the current App Version is the same as the DB Version CheckVersion(); //Cache Mapped Directory(s) CacheMappedDirectory(); //log APPLICATION_START event LogStart(); //Start Scheduler StartScheduler(); //Process any messages in the EventQueue for the Application_Start event EventQueueController oEventController = new EventQueueController(); oEventController.ProcessMessages("Application_Start"); }
public static void CreateImportModuleMessage(ModuleInfo objModule, string content, string version, int userID) { var appStartMessage = new EventMessage { Priority = MessagePriority.High, ExpirationDate = DateTime.Now.AddYears(-1), SentDate = DateTime.Now, Body = "", ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke", ProcessorCommand = "ImportModule" }; //Add custom Attributes for this message appStartMessage.Attributes.Add("BusinessControllerClass", objModule.DesktopModule.BusinessControllerClass); appStartMessage.Attributes.Add("ModuleId", objModule.ModuleID.ToString()); appStartMessage.Attributes.Add("Content", content); appStartMessage.Attributes.Add("Version", version); appStartMessage.Attributes.Add("UserID", userID.ToString()); //send it to occur on next App_Start Event EventQueueController.SendMessage(appStartMessage, "Application_Start_FirstRequest"); }
static void CreateEventQueueMessage(ModuleInfo module, string content, string version, int userId) { var oAppStartMessage = new EventMessage { Priority = MessagePriority.High, ExpirationDate = DateTime.Now.AddYears(Convert.ToInt32(-1)), SentDate = DateTime.Now, Body = "", ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke", ProcessorCommand = "ImportModule" }; //Add custom Attributes for this message oAppStartMessage.Attributes.Add("BusinessControllerClass", module.DesktopModule.BusinessControllerClass); oAppStartMessage.Attributes.Add("ModuleId", module.ModuleID.ToString(CultureInfo.InvariantCulture)); oAppStartMessage.Attributes.Add("Content", content); oAppStartMessage.Attributes.Add("Version", version); oAppStartMessage.Attributes.Add("UserID", userId.ToString(CultureInfo.InvariantCulture)); //send it to occur on next App_Start Event EventQueueController.SendMessage(oAppStartMessage, "Application_Start"); }
internal override void RewriteUrl(object sender, EventArgs e) { var app = (HttpApplication)sender; HttpServerUtility server = app.Server; HttpRequest request = app.Request; HttpResponse response = app.Response; HttpContext context = app.Context; string requestedPath = app.Request.Url.AbsoluteUri; if (RewriterUtils.OmitFromRewriteProcessing(request.Url.LocalPath)) { return; } // 'Carry out first time initialization tasks Initialize.Init(app); if (!Initialize.ProcessHttpModule(request, false, false)) { return; } // URL validation // check for ".." escape characters commonly used by hackers to traverse the folder tree on the server // the application should always use the exact relative location of the resource it is requesting var strURL = request.Url.AbsolutePath; var strDoubleDecodeURL = server.UrlDecode(server.UrlDecode(request.RawUrl)) ?? string.Empty; if (Globals.FileEscapingRegex.Match(strURL).Success || Globals.FileEscapingRegex.Match(strDoubleDecodeURL).Success) { DotNetNuke.Services.Exceptions.Exceptions.ProcessHttpException(request); } try { // fix for ASP.NET canonicalization issues http://support.microsoft.com/?kbid=887459 if (request.Path.IndexOf("\\", StringComparison.Ordinal) >= 0 || Path.GetFullPath(request.PhysicalPath) != request.PhysicalPath) { DotNetNuke.Services.Exceptions.Exceptions.ProcessHttpException(request); } } catch (Exception exc) { // DNN 5479 // request.physicalPath throws an exception when the path of the request exceeds 248 chars. // example to test: http://localhost/dotnetnuke_2/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/default.aspx Logger.Error(exc); } string domainName; this.RewriteUrl(app, out domainName); // blank DomainName indicates RewriteUrl couldn't locate a current portal // reprocess url for portal alias if auto add is an option if (domainName == string.Empty && CanAutoAddPortalAlias()) { domainName = Globals.GetDomainName(app.Request, true); } // from this point on we are dealing with a "standard" querystring ( ie. http://www.domain.com/default.aspx?tabid=## ) // if the portal/url was succesfully identified int tabId = Null.NullInteger; int portalId = Null.NullInteger; string portalAlias = null; PortalAliasInfo portalAliasInfo = null; bool parsingError = false; // get TabId from querystring ( this is mandatory for maintaining portal context for child portals ) if (!string.IsNullOrEmpty(request.QueryString["tabid"])) { if (!int.TryParse(request.QueryString["tabid"], out tabId)) { tabId = Null.NullInteger; parsingError = true; } } // get PortalId from querystring ( this is used for host menu options as well as child portal navigation ) if (!string.IsNullOrEmpty(request.QueryString["portalid"])) { if (!int.TryParse(request.QueryString["portalid"], out portalId)) { portalId = Null.NullInteger; parsingError = true; } } if (parsingError) { // The tabId or PortalId are incorrectly formatted (potential DOS) DotNetNuke.Services.Exceptions.Exceptions.ProcessHttpException(request); } try { // alias parameter can be used to switch portals if (request.QueryString["alias"] != null) { // check if the alias is valid string childAlias = request.QueryString["alias"]; if (!Globals.UsePortNumber()) { childAlias = childAlias.Replace(":" + request.Url.Port, string.Empty); } if (PortalAliasController.Instance.GetPortalAlias(childAlias) != null) { // check if the domain name contains the alias if (childAlias.IndexOf(domainName, StringComparison.OrdinalIgnoreCase) == -1) { // redirect to the url defined in the alias response.Redirect(Globals.GetPortalDomainName(childAlias, request, true), true); } else // the alias is the same as the current domain { portalAlias = childAlias; } } } // PortalId identifies a portal when set if (portalAlias == null) { if (portalId != Null.NullInteger) { portalAlias = PortalAliasController.GetPortalAliasByPortal(portalId, domainName); } } // TabId uniquely identifies a Portal if (portalAlias == null) { if (tabId != Null.NullInteger) { // get the alias from the tabid, but only if it is for a tab in that domain portalAlias = PortalAliasController.GetPortalAliasByTab(tabId, domainName); if (string.IsNullOrEmpty(portalAlias)) { // if the TabId is not for the correct domain // see if the correct domain can be found and redirect it portalAliasInfo = PortalAliasController.Instance.GetPortalAlias(domainName); if (portalAliasInfo != null && !request.Url.LocalPath.ToLowerInvariant().EndsWith("/linkclick.aspx")) { if (app.Request.Url.AbsoluteUri.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)) { strURL = "https://" + portalAliasInfo.HTTPAlias.Replace("*.", string.Empty); } else { strURL = "http://" + portalAliasInfo.HTTPAlias.Replace("*.", string.Empty); } if (strURL.IndexOf(domainName, StringComparison.InvariantCultureIgnoreCase) == -1) { strURL += app.Request.Url.PathAndQuery; } response.Redirect(strURL, true); } } } } // else use the domain name if (string.IsNullOrEmpty(portalAlias)) { portalAlias = domainName; } // using the DomainName above will find that alias that is the domainname portion of the Url // ie. dotnetnuke.com will be found even if zzz.dotnetnuke.com was entered on the Url portalAliasInfo = PortalAliasController.Instance.GetPortalAlias(portalAlias); if (portalAliasInfo != null) { portalId = portalAliasInfo.PortalID; } // if the portalid is not known if (portalId == Null.NullInteger) { bool autoAddPortalAlias = CanAutoAddPortalAlias(); if (!autoAddPortalAlias && !request.Url.LocalPath.EndsWith(Globals.glbDefaultPage, StringComparison.InvariantCultureIgnoreCase)) { // allows requests for aspx pages in custom folder locations to be processed return; } if (autoAddPortalAlias) { AutoAddAlias(context); } } } catch (ThreadAbortException exc) { // Do nothing if Thread is being aborted - there are two response.redirect calls in the Try block Logger.Debug(exc); } catch (Exception ex) { // 500 Error - Redirect to ErrorPage Logger.Error(ex); strURL = "~/ErrorPage.aspx?status=500&error=" + server.UrlEncode(ex.Message); HttpContext.Current.Response.Clear(); HttpContext.Current.Server.Transfer(strURL); } if (portalId != -1) { // load the PortalSettings into current context var portalSettings = new PortalSettings(tabId, portalAliasInfo); app.Context.Items.Add("PortalSettings", portalSettings); // load PortalSettings and HostSettings dictionaries into current context // specifically for use in DotNetNuke.Web.Client, which can't reference DotNetNuke.dll to get settings the normal way app.Context.Items.Add("PortalSettingsDictionary", PortalController.Instance.GetPortalSettings(portalId)); app.Context.Items.Add("HostSettingsDictionary", HostController.Instance.GetSettingsDictionary()); if (portalSettings.PortalAliasMappingMode == PortalSettings.PortalAliasMapping.Redirect && portalAliasInfo != null && !portalAliasInfo.IsPrimary && !string.IsNullOrWhiteSpace(portalSettings.DefaultPortalAlias)) // don't redirect if no primary alias is defined { // Permanently Redirect response.StatusCode = 301; var redirectAlias = Globals.AddHTTP(portalSettings.DefaultPortalAlias); var checkAlias = Globals.AddHTTP(portalAliasInfo.HTTPAlias); var redirectUrl = string.Concat(redirectAlias, request.RawUrl); if (redirectUrl.StartsWith(checkAlias, StringComparison.InvariantCultureIgnoreCase)) { redirectUrl = string.Concat(redirectAlias, redirectUrl.Substring(checkAlias.Length)); } response.AppendHeader("Location", redirectUrl); } // manage page URL redirects - that reach here because they bypass the built-in navigation // ie Spiders, saved favorites, hand-crafted urls etc if (!string.IsNullOrEmpty(portalSettings.ActiveTab.Url) && request.QueryString["ctl"] == null && request.QueryString["fileticket"] == null) { // Target Url string redirectUrl = portalSettings.ActiveTab.FullUrl; if (portalSettings.ActiveTab.PermanentRedirect) { // Permanently Redirect response.StatusCode = 301; response.AppendHeader("Location", redirectUrl); } else { // Normal Redirect response.Redirect(redirectUrl, true); } } // manage secure connections if (request.Url.AbsolutePath.EndsWith(".aspx", StringComparison.InvariantCultureIgnoreCase)) { // request is for a standard page strURL = string.Empty; // if SSL is enabled if (portalSettings.SSLEnabled) { // if page is secure and connection is not secure orelse ssloffload is enabled and server value exists if ((portalSettings.ActiveTab.IsSecure && !request.IsSecureConnection) && (UrlUtils.IsSslOffloadEnabled(request) == false)) { // switch to secure connection strURL = requestedPath.Replace("http://", "https://"); strURL = this.FormatDomain(strURL, portalSettings.STDURL, portalSettings.SSLURL); } } // if SSL is enforced if (portalSettings.SSLEnforced) { // if page is not secure and connection is secure if (!portalSettings.ActiveTab.IsSecure && request.IsSecureConnection) { // check if connection has already been forced to secure orelse ssloffload is disabled if (request.QueryString["ssl"] == null) { strURL = requestedPath.Replace("https://", "http://"); strURL = this.FormatDomain(strURL, portalSettings.SSLURL, portalSettings.STDURL); } } } // if a protocol switch is necessary if (!string.IsNullOrEmpty(strURL)) { if (strURL.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)) { // redirect to secure connection response.RedirectPermanent(strURL); } else // when switching to an unsecure page, use a clientside redirector to avoid the browser security warning { response.Clear(); // add a refresh header to the response response.AddHeader("Refresh", "0;URL=" + strURL); // add the clientside javascript redirection script response.Write("<html><head><title></title>"); response.Write("<!-- <script language=\"javascript\">window.location.replace(\"" + strURL + "\")</script> -->"); response.Write("</head><body></body></html>"); // send the response response.End(); } } } } else { // alias does not exist in database // and all attempts to find another have failed // this should only happen if the HostPortal does not have any aliases // 404 Error - Redirect to ErrorPage strURL = "~/ErrorPage.aspx?status=404&error=" + domainName; HttpContext.Current.Response.Clear(); HttpContext.Current.Server.Transfer(strURL); } if (app.Context.Items["FirstRequest"] != null) { app.Context.Items.Remove("FirstRequest"); // Process any messages in the EventQueue for the Application_Start_FirstRequest event EventQueueController.ProcessMessages("Application_Start_FirstRequest"); } }
/// ----------------------------------------------------------------------------- /// <summary> /// The Commit method finalises the Install and commits any pending changes. /// </summary> /// <remarks>In the case of Modules this is not neccessary</remarks> /// ----------------------------------------------------------------------------- public override void Commit() { //Add CodeSubDirectory if (!string.IsNullOrEmpty(_desktopModule.CodeSubDirectory)) { Config.AddCodeSubDirectory(_desktopModule.CodeSubDirectory); } if (_desktopModule.SupportedFeatures == Null.NullInteger) { //Set an Event Message so the features are loaded by reflection on restart var oAppStartMessage = new EventMessage { Priority = MessagePriority.High, ExpirationDate = DateTime.Now.AddYears(-1), SentDate = DateTime.Now, Body = "", ProcessorType = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke", ProcessorCommand = "UpdateSupportedFeatures" }; //Add custom Attributes for this message oAppStartMessage.Attributes.Add("BusinessControllerClass", _desktopModule.BusinessControllerClass); oAppStartMessage.Attributes.Add("desktopModuleID", _desktopModule.DesktopModuleID.ToString()); //send it to occur on next App_Start Event EventQueueController.SendMessage(oAppStartMessage, "Application_Start_FirstRequest"); } //Add Event Message if (_eventMessage != null) { if (!String.IsNullOrEmpty(_eventMessage.Attributes["UpgradeVersionsList"])) { _eventMessage.Attributes.Set("desktopModuleID", _desktopModule.DesktopModuleID.ToString()); EventQueueController.SendMessage(_eventMessage, "Application_Start"); } } //Add DesktopModule to all portals if (!_desktopModule.IsPremium) { DesktopModuleController.AddDesktopModuleToPortals(_desktopModule.DesktopModuleID); } //Add DesktopModule to all portals if (!String.IsNullOrEmpty(_desktopModule.AdminPage)) { foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { bool createdNewPage = false, addedNewModule = false; DesktopModuleController.AddDesktopModulePageToPortal(_desktopModule, _desktopModule.AdminPage, portal.PortalID, ref createdNewPage, ref addedNewModule); if (createdNewPage) { Log.AddInfo(string.Format(Util.MODULE_AdminPageAdded, _desktopModule.AdminPage, portal.PortalID)); } if (addedNewModule) { Log.AddInfo(string.Format(Util.MODULE_AdminPagemoduleAdded, _desktopModule.AdminPage, portal.PortalID)); } } } //Add host items if (_desktopModule.Page != null && !String.IsNullOrEmpty(_desktopModule.HostPage)) { bool createdNewPage = false, addedNewModule = false; DesktopModuleController.AddDesktopModulePageToPortal(_desktopModule, _desktopModule.HostPage, Null.NullInteger, ref createdNewPage, ref addedNewModule); if (createdNewPage) { Log.AddInfo(string.Format(Util.MODULE_HostPageAdded, _desktopModule.HostPage)); } if (addedNewModule) { Log.AddInfo(string.Format(Util.MODULE_HostPagemoduleAdded, _desktopModule.HostPage)); } } }