5. The solution to the equation $\frac{a x^{2}}{x-1}-2 a=a^{2}+1$ with respect to $x$ is $\qquad$ .
5. When $a=0$, there is no solution; when $a \neq 0$, $x_{1}=a+1, x_{2}$ $=1+\frac{1}{a}$.
Notice that $\frac{a x^{2}}{x-1}-2 a=a^{2}+1$
$$
\Leftrightarrow\left\{\begin{array}{l}
x \neq 1, \\
a x^{2}-(a+1)^{2} x+(a+1)^{2}=0 .
\end{array}\right.
$$

When $a=0$, the left side of the original equation $=0$, the right side $=1$, there is no solution.
When $a \neq 0$, the solutions of equation (1) are $x_{1}=a+1, x_{2}=$ $1+\frac{1}{a}$. Neither of them equals 1. Therefore, they are both solutions to the original equation.