You need to sign in to do that
Don't have an account?

Pagereference is not working as expected
I have a standard page on which I have kept a custom button.
On click of custom button it opens a visualforce page in same window. When I fill in the values in that and click on save button then as per my pagereference method it should redirect back to that standard deal page and it does.
But the URL at top does not change and on click of refresh in browser it directs me back to that visualforce page.
Why is URL at top not changing?
pageref= new Pagereference ('/' + customobject.Id); pageref.setRedirect(true); return pageref;
Try using StandardController.view() instead:
You actually don't need to setRedirect manually in this case, because it should automatically work. The obly problem here is that you're still on the Visualforce server instead of the core instance server. Using the StandardController's view method makes sure you're going back to the correct server name.
All Answers
Try using StandardController.view() instead:
You actually don't need to setRedirect manually in this case, because it should automatically work. The obly problem here is that you're still on the Visualforce server instead of the core instance server. Using the StandardController's view method makes sure you're going back to the correct server name.
This solution is not working for me. After going to the new page, the URL on top of the screen is still showing the visual force server/page, and I still have the development view on.
My specific case: standard controller on the VF page is Shipping Address (custom object). From the VF page, once the button is pressed, I want to go to the opportunity record. I have an opportunity variable in the controller, called "opp".
This is the syntax I am using, and which is still producing the same result as "return new PageReference('/' + opp.id)":
return new ApexPages.StandardController(opp).view();
Is this not a valid usage?
Here is a thread explaining the issue and solution. Redirect was not working because Development Mode was turned on. Should work fine for the end-users.
http://boards.developerforce.com/t5/Visualforce-Development/Pagereference-to-change-page-URL-Set-Redirect-true-not-working/td-p/126129