function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jenna 1982Jenna 1982 

Custom Apex Controller on Public Knowledge Base App

I'm getting an "Access Denied" error when viewing a custom Visualforce page through a public site.  The visualforce page works fine if the Apex references are removed.   I've added the Apex class and VF pages to the "Public Access Settings" profile. 

The Apex class references Topics and TopicAssignments read-only, but I don't see any way to grant access to those objects, and am not sure if that's even the problem.  
 

Questions:
a) Is there a way to get more verbose error logs for errors that occur on a public SF site? 
b) Do I have to specifically permit read access to Topic&TopicAssignments for a public site, and if so, how is that done?  

Thanks in advance.

Jared M NeuferJared M Neufer
Here are my quick first thoughts:

First, have you added the Visualforce pages to both the Site (on the Site Detail page) and the Guest User (Through the Public Access Settings button) on the site?

Second, I see that topics show up under the"General User Permissions" on the Profile page:
User-added image

As for error logs on a public site, Salesforce recently changed this in Winter '17 - 
1. Go to Setup > Monitor > Logs > Debug Logs and set up a User Trace Flag for the Site Guest User
2. On the site, create a cookie using javascript to enable tracking: document.cookie="debug_logs=debug_logs;domain=.force.com";
More info is here: https://releasenotes.docs.salesforce.com/en-us/winter17/release-notes/rn_forcecom_debugging_guest_user.htm (https://releasenotes.docs.salesforce.com/en-us/winter17/release-notes/rn_forcecom_debugging_guest_user.htm#rn_forcecom_debugging_guest_user)
(I'm not sure this will help you out in this case, since it sounds like your controller isn't having a chance to run yet.)
 
Jenna 1982Jenna 1982

Hi Jared,

Thanks for your reply!

Apex & VisualForce:

Sites > Site Detail Page > Site Visualforce Pages does include the name of the VisualForce Page.
Sites > Site Details > Public Access Settings > Enabled Apex Class Access lists the Apex controller Name
Sites > Site Details > Public Access Settings > Enabled Visualforce Page Access lists the VisualForce Page Name

Topics:

There doesn't seem to be a "Read" enable option for Topics under the Public Access Settings > General User Permissions.   I enabled all of the listed permissions in this section as a test;  it did not solve the issue so I set them back to their defaults.

I have enabled the debugging as you suggested and manually added a cookie using the Chrome console, however no log file is showing up.  I will continue to dig -- thank you for letting me know about this feature!!