Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have a sites page, and it seems to work fine from a functional perspective. It has a custom controller that retrieves some data from a custom object and the Contact object, displays the data to the user, and lets them submit an updated version of the data into another custom object.

But after a certain amount of time (24-48 hours), when I go to the page I get a 'Not Authorized message'. After much testing, and thinking it was a a problem with css/statis resources, I have now found that the problem seems to be with the controller (i.e. a page with no references to css/static resources still fails)

When I get the error, I can login to SF and simply view the apex controller class in the usual Setup - Develop - Classes interface, and the public sites page then works again for another 24-48 hours.

What am I missing here? I have different versions of the page setup with cache enabled, and with cache set to false - they all fail.

share|improve this question
    
on your <apex:page> element do you have a cache setting? –  Ryan Guest Oct 29 '12 at 22:10
add comment

2 Answers 2

In case anyone ends up here, I did finally work this out with help from this post: http://www.tgerm.com/2010/10/debugging-sites-authorization-required.html

I set up a debug page as described in the post, included it as a sites page, and when the page failed, this debug page finally revealed the error.

My controller class had a test method in it, which in turn was referencing a second class - and that second class was trying to update a field it wasn't allowed to when running as a Sites user. So for reasons that aren't clear to me, the controller work fine for a while, and the test ran fine when logged in, but at some point, it would error out, and I could only fix it by viewing the class while logged in...

I only worked this out by following the link above, and setting up a debug page that I could access as the Sites User, which finally showed me the error - every other debug method provided no information...

share|improve this answer
add comment

Is it possible the resource your dealing with has some sort of authentication required to load an element.

If so, than you would have a authentication cookie in your browser that would expire and not allow you to authenticate and load an element from the browser after some time.

Although I think authentication cookies expire faster than that.

share|improve this answer
    
I don't think so...it just happened again - didn't work on two different machines/os - I log into SF, view the controller, and now it works on both machines... –  BritishBoyinDC Oct 30 '12 at 16:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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