How to get the simple address of a page in EPiServer

How to get the simple address of a page in EPiServer

This post explains how to get the simple address of a page, if any. As it turns out, it's just a matter of getting the PageExternalURL property.

Migrerad artikel

Denna artikel har migrerats från en tidigare version av vår webbplats och kan därför avvika i utseende och funktionalitet.

Översättning saknas

Den här artikeln är inte översatt till svenska och visas därför på engelska istället.

The following code snippet shows how to retrieve the simple address of an EPiServer page.

If you want to retrieve the friendly URL of an EPiServer page instead, please see my post on How to get the friendly URL of a page in EPiServer CMS.

Implementing the GetSimpleAddress() method

The following method returns the simple address of a page in EPiServer:

public string GetSimpleAddress(PageData page) 
{ 
    string url; 
     
    //Fetch the simple address 
    try 
    { 
        url = (string)page.Property["PageExternalURL"].Value; 
    } 
    catch 
    { 
        url = string.Empty; 
    } 
 
    //Return the regular URL if no simple address was found 
    return (url != string.Empty ? url : page.LinkURL); 
}
Senast uppdaterad: 2016-07-13