A solenoid is simply a coil of wire with a current going through it. Inside the coil the field is very uniform, and the field from a solenoid is essentially identical to the field from a bar magnet.
If we have a long solenoid of length L, current I, and total number of turns N, what is the magnetic field inside the solenoid? Let's use Ampere's Law. What shape should we choose for our amperian loop? Take a careful look at what the field looks like before deciding.
In this situation we'll use a rectangle, and treat the four sides differently.
The magnetic field is essentially parallel to the axis of the solenoid, so B • ds is zero for the two vertical sides of the loop because the field is perpendicular to those sides.
The magnetic field outside the solenoid is considerably smaller than the field inside, so we'll simply neglect that contribution to the integral. In the end the only side of the loop we'll count is the side inside the solenoid. If the width of the loop is w, the line integral is:
∫ B • ds = B w = μo Ienc
How much current passes through the loop? If the solenoid has a uniform number of turns per unit length n = N/L, the current is nwI.
The factors of w cancel, giving B = μo nI
This is an almost uniform magnetic field running parallel to the axis of the solenoid.