In order to obtain a continuous solution we need to impose the compatibility conditions
$$f(0)=U_1,~~~ f(0)=U_2$$
Introduce a function $$h(x,t)=U_1+\frac{x}{L}(U_2-U_1).$$
Now, define a new function $v(x,t)$ by$$v(x,t)=u(x,t)-h(x,t).$$
Our goal is to see what problem $v(x,t)$ satisfies.To this end we note that
$$h_{xx}(x,t)=0,~~~~~h_t(x,t)=\frac{dU_1}{dt}+\frac{x}{L}\left(\frac{dU_2}{dt}-\frac{d U_1}{dt}\right)=0$$
We see that
$$v_t-\beta v_{xx}=(u(x,t)-h(x,t))_t-\beta(u(x,t)-h(x,t))_{xx}=-h_t(x,t)=0.$$
and
$$v(0,t)=u(0,t)-h(0,t)=0,~~~v(L,t)=u(L,t)-h(l,t)=0,$$
$$v(x,0)=u(x,0)-h(x,0)=f(x)-\left(U_1+\frac{x}{L}(U_2-U_1)\right)\equiv v_0(x)$$
Collecting this information we find that $v(x,t)$ satisfies
\begin{align}
v_t(x,t)&=\beta v_{xx}(x,t),~~~0<x<L,~~t>0\\\nonumber
v(0,t)&=0,~~v(L,t)=0\\ \nonumber
v(x,0)&=v_0(x)\nonumber
\end{align}
We assume that the solution will take the form,
\begin{align}
v(x,t)=\psi(x)G(t)
\end{align}
Then
\begin{align*}
G'(t)=-\beta \lambda G~~~~\psi''+\lambda \psi=0,~~~~~\psi(0)=0,~~~\psi(L)=0
\end{align*}
Now we solve the problem,
\begin{align*}
\psi''+\lambda \psi=0,~~~~~\psi(0)=0,~~~\psi(L)=0
\end{align*}
Assuming $\lambda>0$. Then
\begin{align*}
\psi(x)=c_1\cos(\sqrt{\lambda}x)+c_2\sin (\sqrt{\lambda}x)
\end{align*}
Applying the first boundary condition gives,
\begin{align*}
0=\psi(0)=c_1
\end{align*}
Now applying the second boundary condition, and using the above result, we obtain,
\begin{align*}
0=\psi(L)=c_2\sin(L\sqrt{\lambda})
\end{align*}
Now, we are after non-trivial solutions ans so this means we must have,
\begin{align*}
\sin(L\sqrt{\lambda})=0\Rightarrow L\sqrt{\lambda}=n\pi
\end{align*}
The positive eigenvalues and their corresponding eigenfunctions of this boundary value problem are then,
\begin{align*}
\lambda_n=\left(\frac{n\pi}{L}\right)^2~~~~~~~\psi_n(x)=c_2\sin\left(\frac{n\pi x}{L}\right),~~~~n\in\mathbb{N}
\end{align*}
If $\lambda=0$, then the solution of the differential equation in this case is,
\begin{align*}
\psi(x)=c_1+c_2x
\end{align*}
Applying the boundary conditions gives,
\begin{align*}
0=\psi(0)=c_1~~~~0=\psi(L)=c_2L
\end{align*}
So, in this case the only solution is the trivial solution and so $\lambda=0$ is not an eigen value for the boundary value problem.
Assumin that $\lambda<0$. Then,
\begin{align*}
\psi(x)=c_1\cosh\left(\sqrt{-\lambda x}\right)+c_2\sinh\left(\sqrt{-\lambda x}\right)
\end{align*}
Applying the first boundaryu condition gives,
\begin{align*}
0=\psi(0)=c_1
\end{align*}
and applying the second gives,
\begin{align*}
0=\psi(L)=c_2\sinh\left(L\sqrt{-\lambda x}\right)
\end{align*}
So, we are assuming $\lambda<0$ and so $L\sqrt{-\lambda x}\neq 0$ and this means $\sinh\left(L\sqrt{-\lambda x}\right)\neq 0$. We therefore we must have $c_2=0$ and so we can get only trivial solution in this case.
\vspace*{0.2in}
The complete list of eigenvalues and eigenfunctions for this problem are then,
\begin{align*}
\lambda_n=\left(\frac{n\pi}{L}\right)^2~~~~~~~\psi_n(x)=\sin\left(\frac{n\pi x}{L}\right),~~~~n\in\mathbb{N}
\end{align*}
Now let's solve the time differential equation,
\begin{align*}
G'(t)=-\beta \lambda_n G
\end{align*}
Solution of the differential equation is given by,
\begin{align*}
G(t)=ce^{-\beta \lambda_n t}=ce^{-\beta\left(\frac{n\pi}{L}\right)^2t}
\end{align*}
Thus, our product solution are then,
\begin{align*}
v(x,t)=c_2c\sin\left(\frac{n\pi x}{L}\right)e^{-\beta\left(\frac{n\pi}{L}\right)^2t}
\end{align*}
The equation satisfies the given conditon for all integral values of $n$. Hence,
\begin{align*}
v(x,t)=\sum_{n=0}^\infty b_n\sin\left(\frac{n\pi x}{L}\right)e^{-\beta\left(\frac{n\pi}{L}\right)^2t}
\end{align*}
and finally we have
\begin{align*}
u(x,t)=U(x)+\sum_{n=0}^\infty b_n\sin\left(\frac{n\pi x}{L}\right)e^{-\beta\left(\frac{n\pi}{L}\right)^2t}.
\end{align*}
Notice that in this case that as $t\to\infty$ all the exponential terms in the sum tend to zero and we have
\begin{align*}
\lim_{t\to\infty}u(x,t)=U(x)
\end{align*}
This represnts a nonzero and non constant steady state temprature profile.