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

System.currentpagereference() returns null
Hello Community,
i have a confusing issue with the system.currentpagereference() method. First of all, my question is: is there any situation of condition that has to be considered to ensure that system.currentpagereference() does not return null.
I use this in a own visualforce page with custom controller in connection with sites.
Best regards,
Michael
What exactly you want to do ? system.currentpagerefernce() gives you null.... but what if you try .getparameters('id') with that or any member methods for that matter?
Thank you for your quick response.
I use this method to set the startURL for the login mechanism for Sites. The point is, if I receives null from currentPageReference(), I will get a NPE when I call a method on the null value. That was my experience.
Here my login method which is called via commandbutton on a visualforce page via Sites:
The if Condition causes the NullPointerException... Anyone an idea why this happens? Maybe following information helps: I checked in the controller the value of system.currentPageReference() and there it is not null, but in the whole login method it returns null...
It seems that the problem is the combination of using system.currentPageReference() with global class declarations. The exception shows following: System.currentPageReference called without context
Why my visualforce page lose its context?
Did you ever resolve this? I am suddently seeing it and have not been able to determine what was changed to cause it.