1

I have created a site. In this i have 2 VF pages 1st is for register and 2nd is for thanks page. And the 1st VF page have a extension apex class. In a custom object i created a Field set and i am displaying that field set to the 1st VF page.

I have also create an force.com site to expose these VF pages externally. It works fine when i run the VF pages from where the VF page is developed. But When i package these VF pages and installed the package to an another environment. The 1st VF page getting displayed and all fields are getting displayed but when i click submit button i am getting an error.

Authorization Required You must first log in or register before accessing this page. If you have forgotten your password, click Forgot Password to reset it.

Can anybody please guide me what i am doing wrong.

I am using a extension controller to redirect to VFpage2 after saving the record.

public with sharing class onboarding_extCon {
  public ApexPages.StandardController con;
  public onboarding_extCon(ApexPages.StandardController controller) {
      con = controller;
  }
  public pageReference Save()
  {
       con.save();
       PageReference pr = Page.Thankyou;
       return pr;
  }
}

Thinking that this could be problem of redirecting from VF page to VFpage2 I have also changed the thanks page to Google.com. Still it works with sites on the developing environment but not with the installed.

  • Have you added the website to "remote site settings"? – Sagar Pareek Jan 29 '14 at 11:37
  • this 'Authorization Required' message is commonly due to an exception being thrown - the details of the exception will not be revealed to the Site Guest User. Do you get any more details about the error if you set up a Debug Log on Site Guest User from the Setup > Monitoring menu? – bigassforce Jan 29 '14 at 16:46
1

When you create a package you specify a namespace, and the Visualforce pages will take on this namespace. For example, I have a project tracking package with a timesheet page. In the development environment I can open:

https://<instance>/apex/Timesheet 

and everything works fine. When I package it in the BBPM namespace, that page gives me an error as it doesn't exist. Instead, I have to prefix the page with the namespace:

https://<instance>/apex/BBPM__Timesheet

If you use the Page notation to generate page references, rather than the URL snippet, that will handle the namespace for you:

PageReference pr = new PageReference('/apex/Timesheet');

I use:

PageReference pr = Page.Timesheet;
  • I am getting the same issue. When i try to access the thankyou page directly it works. But not bale to access the controller because records are not getting saved. – AnuRaj Jan 29 '14 at 12:28
  • When i try to access the VF page from the browser <siteurl>/<namespace>__thanks i am able to access that page. I changed the redirection as mentioned by you and it still throws up the same error. The issue could be that the save method on the extension controller is throwing some exception as the records are not getting saved. updated the question with the full controller code. Access to the concerned custom object is also provided to the site users profile – AnuRaj Jan 29 '14 at 12:54
  • Try previewing the site in admin mode - that should show you any exceptions. You can also turn on debug logging for the guest profile. Other things to check are the sharing model for the sobjects (make sure the guest user profile can see them) whether the guest profile has appropriate CRUD permissions and also whether the guest profile has the correct field level security for all fields accessed.. – Bob Buzzard Jan 29 '14 at 12:56
0

Thanks guys for your help. I have resolved this issue. I declared my Apex class as global. Not the site is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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