I'm attempting to do a redirect from a visualforce page to a salesforce page but when it loads, I end up with the login.salesforce.com page.
The visual force controller builds the http request, and retrieves the response to send back to javascript to render the that response as HTML.
@RemoteAction
public static string HTTPRequest(string requestURL)
{
HttpRequest request = new HttpRequest();
request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
request.setEndpoint(requestURL);
request.setCompressed(true);
request.setMethod('GET');
Http http = new Http();
HttpResponse response = http.send(request);
return response.getBody();
}
I figured that if I add the authorization header with the current user session ID (as the user is currently logged into a visual force page), that it would authenticate but I appear to be wrong.
After the login page displays, and if I manually log in, i get the expected page that I want to display.
Is this possible to do and have I just missed something?
EDIT
I forgot to mention that the RemoteAction is directly affecting an IFrame... thus bypassing cross-origin issues and rendering the content within an IFrame without reloading the page. Reloading the page is not an option due to content that remains "open" within the page.