Making your URLs work when running inside your Personal Area

Making your URLs work when running inside your Personal Area

On some situations you may have stored absolute URLs in your eSpace that would need to point to the Publish Area or the Personal Area depending on where you are running your application.

For example, you may have a number of URLs saved on the database in the format "/myapplication/mypage.aspx", and use them to build a navigation menu. The problem is, if you are testing the eSpace inside your Personal Area, when you click this link, you will be taken to the "mypage.aspx" in the Publish Area.

To solve this problem, Service Studio provides you with built-in functions that automatically manipulate the URLs for you, the most important being 'AddPersonalAreaToURLPath'.

This function receives an URL as argument, and returns an URL with the Personal Area name added to it if you are running your eSpace inside a Personal Area. If you are using the application in the Publish Area, the URL will be unchanged.

If you are running inside the Personal Area named "myuser":

AddPersonalAreaToURLPath("/myapplication/mypage.aspx") returns "/myapplication/myuser/mypage.aspx"

AddPersonalAreaToURLPath("http://hostname/myapplication/mypage.aspx") returns "http://hostname/myapplication/myuser/mypage.aspx"

AddPersonalAreaToURLPath("mypage.aspx") returns "mypage.aspx"

If your URLs point to other eSpaces, the function behavior will be the same, for example:

AddPersonalAreaToURLPath("/otherapplication/page.aspx") returns "/otherapplication/myuser/page.aspx"

Note that you will also need to have the 'otherapplication' eSpace running in the 'myuser' Personal Area for the returned link to work, but you will save a lot of time by always being able to test your eSpace with 'Run' instead of '1-Click Publish'.

For more information check Service Studio help for 'AddPersonalAreToURLPath', and see also the functions 'GetPersonalAreaName', 'GetOwnerURLPath' and 'GetBookmarkableURL'.