How do I apply Ampere's law for a solenoid with a core?
The apparent contradiction arises because you're confusing \$ H\$ with \$ B\$. Remember that \$ H\$ is insensitive to whether or not a magnetic material is present (analogously to how \$ D\$ is insensitive to whether a dielectric is present for electric fields). So the \$ H\$ field between \$ dh\$ is not stronger than the \$ H\$ field between \$ bf\$ (which is not completely zero, and is only neglected because the magnetic flux in the core is much stronger, and the flux is usually what we care about in practical scenarios because it features in Faraday's law). The \$ B\$ field is of course much stronger between \$ dh\$ but as I said, Ampere's law concerns \$ H\$, not \$ B\$. If you want to apply Ampere's law with \$ B\$ rather than \$ H\$, then you need to take into account the permeabilities of the core and the air as you do your line integrals and this difference will account for the apparent contradiction.