In this tutorial, you will learn how to get the Url for any Episerver content page... in code 💥. There are several ways of getting a Url for a page. There are several ways of accessing a Url within Episerver. If you want a Url in a view you can use the PropertyFor()
helper. PropertyFor()
is an HTML helper, meaning it can not be used within a controller. If you are within a controller, you can access a URL using the UrlBuilder
and the UrlRewriteProvider
, like this:
Feel free to copy this method and add it to your codebase. You can then call the method like this:
It is also possible to get the page URL from route data. To learn how to do that, read this tutorial.
Happy Coding 🤘