I am trying to open a normal visualforce page (that is NOT a part of the managed package) from a visualforce page that is IN managed package.

This button I have on the visualforce page in manage package:

<apex:commandButton value="Open" onclick="window.open('apex/MyPage'); return false;" />

The MyPage is NOT in the managed package.

By clicking on the button a new popup window appears, so javascript works well.
But the problem is that I am getting the following error message and no content of the MyPage:

URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com.

After some research I've found a difference between URL of the both pages.

Managed package visualforce page with that command button:


Another page that should be opened (MyPage, not in managed package) is opened with the same prefix in URL. But if I replace the PREFIX with a c then the page will load without problems:

https://customDomainName--c.csXX.visual.force.com/apex/MyPage          <- this works
https://customDomainName--PREFIX.csXX.visual.force.com/apex/MyPage     <- this not

How you can see the only difference is that external page opened with a prefix in URL could not be shown :(

My question is, what is wrong with my button? Why an "external" page opens with a wrong URL? Is it a managed package "feature"? How can I avoid this?



  1. URL No Longer Exists
    • Error is happening because your path to the page is incorrect and is missing the leading / which creates a URL which is relative to the current page rather than relative to the host.
  2. Path to the page outside of the managed package namespace
    • The default VF namespace is c__ and you can specify this in your page path. This allows you to avoid hardcoding a fully qualified URI.

<apex:commandButton value="Open" onclick="window.open('/apex/c__MyPage'); return false;" />

Related: How to redirect to default namespace vf page from managed package vf page?

  • ooh, didn't know about the __c prefix, nice Sep 1 '14 at 18:08
  • WOW! Great hint Mark, didn't know about c__PageName, but this is so obvious! :) Many thanks. Sep 2 '14 at 6:58

I think pages opened from within a managed package must always be fully qualified with the full URL, so your button would have to be:

<apex:commandButton value="Open" onclick="window.open('https://c.csXX.visual.force.com/apex/MyPage'); return false;" />

Obviously, this will give you some challenges to get the correct pod in your URL, but other than that should work.

I believe it is indeed a feature of managed packages.

  • I've just tried to hard code the whole correct URL (w/o prefix) to the button and a popup page opens correctly. So the challenge is to generate this URL without prefix dynamically :) Thanks. Sep 1 '14 at 14:43
  • Would a custom setting be dynamic enough perhaps? Sep 1 '14 at 14:56
  • I dont think so. It is not always the same. Sep 1 '14 at 15:05

I'm not sure that this will solve your problem but try this one :

< apex:commandButton value="Open" onclick="window.open('{!$Page.MyPage}'); return false;" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.