FAQ
overflow

Great Answers to
Questions About Everything

QUESTION

I am trying to use VF remoting in a public site and get the error 'Visualforce Remoting Exception: Error parsing json response: 'Unexpected token <'. Logged in?' when viewing page from a public site guest user context. The remoting is being used by a jquery autocomplete component.

If I test the page from a non-url redirected, sys admin perspective it works as expected.

The site does use URL rewrites, and the site guest user profile has access to all information being searched in the database. It seems to be an authentication issue? If anyone has seen anything like this and has any suggestions re resolution they'd be most appreciated. Im stuck!

Cheers, CH

{ asked by CloudHugger }

ANSWER

Ok - looks like someone else sorted this and I just stumbled onto their great response.

The issue lies in the url rewriter class, and the mapping from an external 'pretty' url to an internal url with '/apex/' in it makes SF decide it needs to be logged in whilst accessing the remoting logic.

Thus, when the VF remoting request is made we need to ignore it and let it pass unchanged. Per the great solution writeup at following link,you check the inbound url for contains 'apexremote' as indicator of whether to exclude from mapping logic.

See https://developer.salesforce.com/forums/ForumsMain?id=906F000000099DOIAY for more details.

{ answered by CloudHugger }
Tweet