You need to sign in to do that
Don't have an account?

Get Secure Web Address programmatically?
Is there a method to get a Site's 'Secure Web Address' programmatically? Maybe via an undocumented method call?
I want to avoid using a Custom Setting entry to store a system generated value which is already defined by the system out of the box and I also don't want logic in code to programmatically build a URI in a controller.
Looking for the secure equivalent of Site.getDomain()
Thanks in advance!
Mark
Hi,
There is no any standard method to access Site's 'Secure Web Address'. You need to construct it programatically in controller.
All Answers
Hi,
Try the below code snippet to get the URL:
URL.getSalesforceBaseUrl().toExternalForm();
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi,
There is no any standard method to access Site's 'Secure Web Address'. You need to construct it programatically in controller.
Thank you for the confirmation.
For anyone coming along later, some context and how I got here:
In a sandbox org the Site force.com domain is the same for both secure and not
however, in a production org this is not the same pattern.
This data needs to be based on the org context and it would be REALLY nice to simply make a system method call that will return this information, which should be trivial considering it's already provided on the Site detail page.
For the sake of time, I implemented this as a custom setting value which stores the 'Secure Web Address' domain value for the org. The value is read by the page controller and a secure URL is returned by a controller method call.
Thank you for your help!
Mark