Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pete 152 posts 176 karma points
    Oct 28, 2009 @ 16:43
    Pete
    0

    The bug with URL Rewriting & Login redirect

    It's a pretty commonly noted problem with the URL Rewriting software in Umbraco but not one I've seen solved. 

    The issue is when:

    1. user navigates to a protected page while not logged in

    2. user logs in

    3. user is redirected to ugly url instead of the nice url

    This is expected from the .NET control when placed in BeginRequest, AuthenticateRequest but is fine if placed in AuthorizeRequest. 

    Unfortunately this workaround can't be used with this url rewriting package.

     

    Anyone found a way around this?

  • Pete 152 posts 176 karma points
    Oct 28, 2009 @ 17:09
    Pete
    0

    Fixed it myself ;-) 

     

    I set a session variable on page load in my login control if !Page.IsPostBack.

     

    I then use that session variable as the destinationpageurl in the login control in the onloggingin event.

  • Pete 152 posts 176 karma points
    Nov 19, 2009 @ 12:19
    Pete
    0

    The code, for anyone who's interested:

    In Page_Load:

     

    if (!Page.IsPostBack)

                {

                    Session["OriginalUrl"] = Request.Url.ToString();

                }

     

     

    private void QueryLessUrl(System.Web.UI.WebControls.Login ctrl)

            {

                string newUrl = string.Empty;

                if (!string.IsNullOrEmpty((string)Session["OriginalUrl"]))

                {

                    newUrl = Session["OriginalUrl"].ToString();

                    if (!String.IsNullOrEmpty(Request.Url.Query))

                        newUrl = newUrl.Replace(Request.Url.Query, String.Empty).Replace("?DataNodeId=",string.Empty);

                    ctrl.DestinationPageUrl = newUrl;

                }

            } 

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies