<%= Localization.GetString("SourceUrlHeaderLabel", LocalResourceFile) %> | +<%= Localization.GetString("TargetUrlHeaderLabel", LocalResourceFile) %> | ++ |
---|---|---|
+ | + | + + + + + | +
+ |
+
<%= Localization.GetString("Url.Header", LocalResourceFile) %> | +<%= Localization.GetString("Occurrences.Header", LocalResourceFile) %> | +<%= Localization.GetString("Actions.Header", LocalResourceFile) %> | +
---|---|---|
+ | + | + + + | +
{0}
", + Localization.GetString("Dnn404PortalSettingAbsent.Text", LocalResourceFile)))); + } + + // if it's not a 404, we only want to log when the requested URL is for a deeper level than the page itself is + //// TODO: This doesn't work as intended, so it's gone + //// so OnlyLogwhen404 should be true if the request is for the same or higher level + ////Request.RawUrl.Count(t => t == '/') <= PortalSettings.ActiveTab.Level + 1; + var onlyLogWhen404 = true; + + Common.Logger.Debug($"Calling DoRedirect From View.ascx OnInit"); + RedirectController.DoRedirect(LoggingPlaceholder.Controls, true, onlyLogWhen404); + + if (!IsPostBack) + { + if (TabPermissionController.CanAdminPage()) + { + UnhandledUrlsPanel.Visible = true; + } + } + } + + private void Page_PreRender(object sender, EventArgs e) + { + string incoming = (string)HttpContext.Current.Items["40F_SEO_IncomingUrl"]; + + // check if IIS/ASP.NET/DNN already found this to be a 404 + if (Response.Status == "404 Not Found") + { + if (Response.StatusCode == (int)HttpStatusCode.NotFound && !string.IsNullOrEmpty(incoming)) + { + Common.Logger.Debug($"Logging redirect from Context_EndRequest. incoming:[{incoming}]"); + RedirectController.AddRedirectLog(PortalId, incoming, ""); + } + } + + // DNN returns 200 for static files that are actually 404's + if (RedirectController.RequestHas404Detected() && Response.StatusCode == (int) HttpStatusCode.OK) + { + //RedirectController.AddRedirectLog(PortalId, incoming, ""); + RedirectController.SetStatus404(); + } + } + + protected void Page_Load(object sender, EventArgs e) + { + ClientResourceManager.RegisterScript(Page, "resources/shared/scripts/knockout.js", FileOrder.Js.jQuery); + ClientResourceManager.RegisterScript(Page, "resources/shared/scripts/knockout.mapping.js", FileOrder.Js.jQuery + 1); + ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn); + ServicesFramework.Instance.RequestAjaxAntiForgerySupport(); + ServicesFramework.Instance.RequestAjaxScriptSupport(); + ClientResourceManager.RegisterScript(Page, "desktopmodules/40fingers/seoredirect/js/40F-Common.js", FileOrder.Js.jQuery); + ClientResourceManager.RegisterScript(Page, "desktopmodules/40fingers/seoredirect/js/SeoRedirect.js", FileOrder.Js.jQuery); + + UnhandledUrlsPanelHeader.Text = String.Format(Localization.GetString("UnhandledUrlsPanelHeader.Text", LocalResourceFile), Config.NoOfEntries); + + } + + + public ModuleActionCollection ModuleActions + { + get + { + var actions = new ModuleActionCollection(); + actions.Add(GetNextActionID(), + Localization.GetString("EditModule.Action", LocalResourceFile), + ModuleActionType.EditContent, + "", + "", + EditUrl(), + false, DotNetNuke.Security.SecurityAccessLevel.Edit, + true, + false); + + return actions; + } + } + } +} \ No newline at end of file diff --git a/View.ascx.designer.cs b/View.ascx.designer.cs new file mode 100644 index 0000000..bcb708b --- /dev/null +++ b/View.ascx.designer.cs @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +//To use regex matching in URLs, check the "Use Regex" box on the Edit Mappings page. The incoming URL can now contain a regular expression, e.g.:
+
^http[s]?://.*\.40fingers\.net.*$+ will match any url on http or https for 40fingers.net or any subdomain. + +