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
Priti ShelkePriti Shelke 

Force.com site not redirecting to another visualforce page

Hi all,
I have created 2 visual force page, login page and detail page after successful login it will redirect to next detail page. 
Now I have added login page to force.com site but it not redirecting to the detail page(In URL showing page name and record Id correctly).
redirecting to below URL.
'https://employeeloginpage-developer-edition.ap5.force.com/EmployeeDetailPage?id=0037F00000Slwc2QAB'
I have added this page to profile and gives all required access.
Could anyone please guide me as I am not getting any online solution.

Thanks 
Amit Singh 1Amit Singh 1
Hi Priti,

Will you please post the code of your Controller class where you have written the logic of redirection? After seeing the Code we will be able to provide you the possible solution.

Regards,
Amit
Priti ShelkePriti Shelke
public class EmployeeLogin {
    Contact con{get;set;}
    public List<Contact> contactList;
    public String username {get; set;}
    public String password {get; set;}
    // Consturctor for initializing variables
    public EmployeeLogin()
    {
        con = new Contact();
        contactList = new List<Contact>();
    }
    
    public PageReference redirect() 
    {  
        PageReference newPage;
        try
        {
            if(username != '' && username != null && password != '' && password!=null){
                contactList = [select Id from Contact where Email =: username AND Password__c =:password];
            }    
            system.debug(contactList);
            if(contactList.size()>0) {
                newPage = new PageReference('/apex/EmployeeDetailPage?id='+contactList[0].id);
                newPage.setRedirect(true); 
            }else{
               ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,system.label.Error_Message2)); 
            } 
        }    
        catch(Exception e3)
        {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,system.label.Error_Message2));
        } 
        
        return newPage; 
        
    }    
}
Amit Singh 1Amit Singh 1
What is the URLPathPrefix of your site? You can find using the below query
SELECT Subdomain, UrlPathPrefix FROM Site

and then try urlPathPrefix instead of the apex. For Example, If your pathprefix is test then URL will be
/test/EmployeeDetailPage?id=

Hope this will help :)
Priti ShelkePriti Shelke
Still redirecting to the same page with the change in URL
(https://employeeloginpage-developer-edition.ap5.force.com/mysite/EmployeeDetailPage?id=0037F00000Slwc2QAB) \

User-added image
Amit Singh 1Amit Singh 1
Please check the VF page, Apex and Object Level access for the profile. Also, turn the debug log on and see if you get any error over there.
Priti ShelkePriti Shelke
Ok Sure
Thanks for your time :)