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 mentions in the comments, you want to replace return null
with this at the end of your upload
method.