From e46be463e80db34379d3cc9a77297b2c4f18da15 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 21 Dec 2014 03:56:15 +0100 Subject: [PATCH] URL prettification complete (I think) --- Site5/Controls/v5/Base/MainMenu.ascx.cs | 9 ++++++++- Site5/Global.asax | 12 +++++++++--- Site5/Master-v5.master | 2 +- Site5/Security/Login.aspx.cs | 2 +- Site5/web.config | 15 +-------------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Site5/Controls/v5/Base/MainMenu.ascx.cs b/Site5/Controls/v5/Base/MainMenu.ascx.cs index 019d3d4d..2ea6ac95 100644 --- a/Site5/Controls/v5/Base/MainMenu.ascx.cs +++ b/Site5/Controls/v5/Base/MainMenu.ascx.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Web.UI; using System.Xml.Serialization; @@ -51,6 +52,12 @@ namespace Swarmops.Controls.Base { output.Write ("
  • ", menuItem.Type); string localizedText = "RESOURCE NOT FOUND"; + string prettyNavUrl = menuItem.NavigateUrl; + + if (!Debugger.IsAttached) + { + prettyNavUrl = prettyNavUrl.Replace ("/Pages/v5/", "/").Replace (".aspx", ""); + } if (!String.IsNullOrEmpty (menuItem.ResourceKey)) { @@ -83,7 +90,7 @@ namespace Swarmops.Controls.Base case MenuItemType.Link: output.Write ( "{2}", - menuItem.ImageUrl, menuItem.NavigateUrl, localizedText, iconSize); + menuItem.ImageUrl, prettyNavUrl, localizedText, iconSize); break; case MenuItemType.Disabled: case MenuItemType.BuildNumber: diff --git a/Site5/Global.asax b/Site5/Global.asax index 8ccfdcac..024afbc4 100644 --- a/Site5/Global.asax +++ b/Site5/Global.asax @@ -29,6 +29,15 @@ { // The culture was once set here for localization, but Mono resets CultureInfo before entering the page cycle. // Setting the CultureInfo has been moved to PageV5Base.OnPreInit(). + + // If we've been called as "/Default.aspx", strip it mercilessly and redirect + + string callUrl = Request.Url.ToString(); + + if (callUrl.EndsWith("/Default.aspx")) + { + Response.Redirect(callUrl.Substring(0, callUrl.Length - "/Default.aspx".Length), true); // "true" prevents further processing + } // Testing for page rewrite. @@ -48,9 +57,6 @@ Context.RewritePath (rewrittenCandidate); } } - - - } diff --git a/Site5/Master-v5.master b/Site5/Master-v5.master index f5524961..3ab6813b 100644 --- a/Site5/Master-v5.master +++ b/Site5/Master-v5.master @@ -125,7 +125,7 @@
    |
    -
    | 
    +
    | 
    |
    | 
    diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs index 1cd811d1..38b4280e 100644 --- a/Site5/Security/Login.aspx.cs +++ b/Site5/Security/Login.aspx.cs @@ -28,7 +28,7 @@ namespace Swarmops.Pages.Security if (!SwarmDb.Configuration.IsConfigured()) { - Response.Redirect ("/Pages/v5/Init/", true); + Response.Redirect ("/Init/", true); return; } diff --git a/Site5/web.config b/Site5/web.config index 3e81f77d..4ca382b1 100644 --- a/Site5/web.config +++ b/Site5/web.config @@ -19,7 +19,7 @@ - + @@ -53,18 +53,5 @@ - - - - - - - - - - - - - \ No newline at end of file