The most proper way to construct a redirect PageReference
is to use the StandardController.view
method. In this case, you need to also construct the record itself with the varCaseId
.
PageReference view = new ApexPages.StandardController(new Case(Id=varCaseId)).view();
return view;
You don't even need to cache it, I just do so here because I find it more illustrative. As @Ilya@Ilya mentions in the comments, you want to replace return null
with this at the end of your upload
method.
For custom Visualforce Pages
, the programmatic approach would be:
PageReference detail = Page.CaseDetail;
detail.getParameters().put('id', varCaseId);
return detail;