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
Salesforce_ckumarSalesforce_ckumar 

Force.com site -- Redirect problem

when a search button on vf page is clicked, serch function in class makes request for facebook verification code and then redirectes page along with verification code...

visual force page tag contains action attribute which makes initialAction function to get executed, it checks whether URL contains verification code,, if yes, page gets redirected to URL specified in pagereference object but the URl gets appended with %23_=_

 

i am not able to find, why %23_=_ is getting appended to url....

 

vf page :

 <apex:page standardController="Event__c"  extensions="TEventSearch" action="{!initialAction}">

<apex:image value="{!$Resource.theme1_searchButton_jpg}" onclick="doSave()" />
 <script type="text/javascript">  
 function doSave()
 { 
 document.getElementById("{!$Component.hidVal}").value = strUid1;
 paraFunction();
 }
</script>
<apex:actionFunction name="paraFunction" action="{!search}" status="statusSearch" /> 

</page>

 

Apex class code :

public class TEventSearch
{

public TEventSearch(ApexPages.StandardController controller)
{

}

public PageReference initialAction()
{
   
    PageReference p = null;
       
    if(ApexPages.currentPage().getParameters().containsKey('code'))
    {
        p = new PageReference('https://event-management-developer-edition.ap1.force.com/TEventSearch');
        p.getParameters().put('res', 'fb');
        p.setRedirect(true);
    }

    return p;
}

public PageReference search()
{

 AccessTokenAndkey__c fapp;
 fapp = [Select Id, UserName__c,intRedirect__c, Password__c, Name, Key__c, Extended_Permission__c, Code__c, ApplicationSecret__c, ApplicationId__c, AccessToken__c From AccessTokenAndkey__c where Name = :'Facebook'];
 String exPerms = '&scope=user_about_me,user_activities,user_birthday,user_events,user_likes,user_location,user_website,read_requests,read_stream,create_event,publish_stream,rsvp_event';
String rediruri = 'https://event-management-developer-edition.ap1.force.com/TEventSearch';

String authuri = 'https://graph.facebook.com/oauth/authorize?client_id='+fapp.ApplicationId__c+'&redirect_uri='+EncodingUtil.urlEncode(rediruri, 'UTF-8')+exPerms;
pgRef = new PageReference(authuri);
pgRef.setRedirect(true);
return pgRef;

}

}

 

 

 

NzgonNzgon

Url encoding is taking place here.

%23 is encoding for sign #.

 

You can see all codes here:

http://www.w3schools.com/TAGS/ref_urlencode.asp

 

Nash