In order to overcome ‘URL No Longer Exists. You have attempted to reach a URL that no longer exists on salesforce.com’ error, avoid using ‘/’ at the end of the URL.
Correct Code:
pageReference pg = new pageReference(‘/apex/ExportAsCSV’);
pg.setRedirect(true);
return pg;
Incorrect Code:
pageReference pg = new pageReference(‘/apex/ExportAsCSV/’);
pg.setRedirect(true);
return pg;
‘/’ should not come at the end.
Cheers!!!