A long solenoid can be approximated to an infinite solenoid, if the ratio between its radius and length is very small. The magnetic field due to an infinite solenoid, on it's axis is one of the very few situations in which the Biot-Savart Law is useful. Consider the field at a distance $z$ away from the centre of a ring current, of radius $R$. It isn't much work to show that the field due to this ring is $$B(z)=\frac{\mu_{0}IR^2}{2(R^2+z^2)^{3/2}}$$
If a solenoid has n turns per unit length, the current through an element of thickness $dz$ would be $In(dz)$
Therefore,
$$\int_{-\infty}^{+\infty} dB(z)=\int_{-\infty}^{+\infty}\frac{\mu_{0}nIR^2dz}{2(R^2+z^2)^{3/2}}$$
Integrating this gives,
$$B(z)=\mu_{0} n I$$
Ampere Law reads, $$\oint\vec B\cdot d\vec l=\mu_{0}I_{enc}$$
Using symmetry arguments, one can eliminate the radial and tangential components of the fields (along $\hat r$ and $\hat \phi$). Considering an amperean square loop of one length $l$ , one side of which coincides with z axis, and the other outside the solenoid. Using amperes Law,
$$B_{in} - B_{out} = \mu_{0} n I$$
but since $B_{in}=\mu_{0} n I $ we can conclude that $B_{out} $ is 0. Very simple.
This result holds for only infinite case, and analysis on non infinite solenoid is more involved.
If for some reason one doesn't like this analysis, one can also do an analysis on a toroid, for which, one can systematically show that the field goes to 0 outside the toroid. Then, one can take the infinite radius limiting case of a toriod, which is nothing but a solenoid. Again, this is the infinite case.