DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Get friendly URL for redirect

Sort:
You are not authorized to post a reply.





New Around Here





    I have some simple code to manage redirects

            If Request.Cookies("lastURL") Is Nothing Then
                Dim aCookie As New HttpCookie("lastURL")
                aCookie.Value = HttpContext.Current.Request.Url.ToString()
                aCookie.Expires = DateTime.Now.AddDays(1)
                Response.Cookies.Add(aCookie)
            Else 
                Response.Cookies("lastURL").Value = HttpContext.Current.Request.Url.ToString()
                Response.Cookies("lastURL").Expires = DateTime.Now.AddDays(1)
            End If

    For example if I navigate to:
    https://[site]page/time-to-address-the-inter-without-operability-issue

    that script will cache
    https://[site]/Default.aspx?tabid=33&artmid=383&articleid=2495&language=en-US

    This sadly will break if I'm trying to direct to a DNN easy news article (not anything else)

    Was hoping I can figure out how to get the URL friendly name with the same bit of code

    My google fu is failing me and just keeps saying the same or similar things that just get me the original

    Thanks
     






    Veteran Member





      Well, the second URL is what DNN always sees.  Well, something like that.  If you're concerned about the SEO version of your URL - the public-, human-version - then, you'll want to check the URL using a different variable. 

      Most likely, you'll want to no longer use this:  

      HttpContext.Current.Request.Url.ToString()

      And instead, use this:  

      HttpContext.Current.Request.Url.AbsoluteUri

      Or this:

      HttpContext.Current.Request.Url.AbsolutePath

      Or this:  

      HttpContext.Current.Request.Url.PathAndQuery






      New Around Here





        nm work around found 

        Always happens right after I post to a forum

        You are not authorized to post a reply.

        These Forums are dedicated to the discussion of DNN Platform.

        For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

        1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
        2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
        3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
        4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
        5. No Flaming or Trolling.
        6. No Profanity, Racism, or Prejudice.
        7. Site Moderators have the final word on approving / removing a thread or post or comment.
        8. English language posting only, please.

        Would you like to help us?

        Awesome! Simply post in the forums using the link below and we'll get you started.

        Get Involved