# Page number of ToC should be in the header

The page number is in the footer not in the header, I used the answer of @cmhughes in this link and it was good but as it is well known that the ToC may last for 4 or 5 pages not only one, that is, the first page numbering is still in the footer while the other pages were corrected. I need to make the page number of the first page of the ToC to be in the right side of the header. I used this code in the class:

%%%%%%%%%%% Table of Contents started here %%%%%%%%%%%%%%%%%%%

\setcounter{tocdepth}{6}
\newcounter{dummy}
\refstepcounter{dummy}
\renewcommand\tableofcontents{

\begin{spacing}{1}{

\setlength{\parskip}{1pt}
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter{\contentsname
\@mkboth{
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}
\@starttoc{toc}
\if@restonecol\twocolumn\fi
\cleardoublepage
}\end{spacing}
}


and in the main file of my thesis I used this code:

\fancyhf{}
\pagestyle{fancy}

By default, \chapters set their first pages in the plain page style using \thispagestyle{plain}. A crude yet feasible solution would be to include
\let\ps@plain\ps@fancy% Plain page style = Fancy page style

as part of your redefinition of \tableofcontents. This overwrites the plain page style (stored in \ps@plain) with that of fancy (stored in \ps@fancy). Placing it inside a group will localize the change.