We propose a novel approach for solving the optimal feedback control problem. Following our previous research, we formulate the problem as a Hamiltonian system by using the necessary conditions for optimality, and treat the resultant phase flow as a canonical transformation. Then starting from the Hamilton-Jacobi equation for generating functions we derive a set of 1st order quasilinear partial differential equations with the appropriate initial or terminal conditions, which forms the well-known Cauchy problem. These equations can also be derived by applying the invariant imbedding technique to the two point boundary value problem. The solution to this Cauchy problem is utilized for solving the Hamiltonian two point boundary value problem as well as the optimal feedback control problem with hard and soft constraint boundary conditions. As suggested by the illustrative examples given, this method is promising for solving problems with control constraints, non-smooth control logic, and nonanalytic cost function.