Copied to clipboard

Flag this post as spam?

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


  • Carlos Mosqueda 185 posts 277 karma points
    Jan 02, 2019 @ 22:19
    Carlos Mosqueda
    0

    How to get the current page URL without the full path

    Hello, I am trying to get the current page URL from Umbraco but I don't want the full folder path, just the current one.

    So in my case the URL would be something like this:

    https://mysite.com/somepage/some-other-page/my-page-i-want-url-for

    In this case you can see I actually only want the part "my-page-i-want-url-for". I tried @Model.Url, but that gives me the fully qualified URL.

    Thanks in advance.

  • Amir Khan 1199 posts 2567 karma points
    Jan 03, 2019 @ 00:55
    Amir Khan
    0

    Could you do something like this or are you worried about there being other special characters in there? Its not fool proof but it will get the job done if you can control the page names somewhat: @Model.Name.Replace(" ", "-")

    -Amir

  • 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