Hi EveryOne,
Basically when we click on Button we will perform some action in controller and we will redirect to same using ApexPages.CurrentPage().Whenever we use that functionality some case we will get viewState in the URL.So workaround it to remove the ViewState and to form actual URL agian we need to de below thing.
Input:
ViewState URL:
https://c.cs9.visual.force.com/apex/PageName?com.salesforce.visualforce.ViewStateCSRF=DDJ0GM8ZVlS85i.RSAD.zXbq2770v0bY5Ypf3JQQI.j3VWgsnKQUR30SUBWmc3pyk8iF.xW2Ev49fvI7IY72CVu8bUX0Th6mxUcy3UJXlPdcOisfzgca39Va2H2t2AhgEbBwLEx6.g8voCONr_8IZRIQsqQ%3D&com.salesforce.visualforce.ViewStateVersion=201312112156340748&delMetricId=a2LK0000000QxpVMAS&id=a1DK000000wpLTsMAM&thePage%3AtheBlock%3Aj_id402%3Aj_id403=thePage%3AtheBlock%3Aj_id402%3Aj_id403&thePage%3AtheBlock%3Aj_id402%3Aj_id403%3Aj_id407%3A0%3Aj_id430=thePage%3AtheBlock%3Aj_id402%3Aj_id403%3Aj_id407%3A0%3Aj_id430
public PageReference yourmethodname(){
//Your Logic
pageReference pref = ApexPages.currentPage();
Id id = pref.getParameters().get('Id');
pref .getParameters().clear();
pref .getParameters().put('Id', id);
pref .setRedirect(true);
return pref;
}
OutPut : https://c.cs9.visual.force.com/apex/PageName?id='recordId'