In this paper, we will find in terms of Fourier integrals an exact expression for the magnetic and electric fields generated by an infinite solenoid where an arbitrary current density J(t) flows. Considering the central region of an infinite solenoid, we will obtain an exact expression relating the flowing current and the magnetic and electric fields as functions of the time. Being an exact expression, it will allow us to go beyond the quasistatic approximation. The result can apply in theoretical problems and experimental setups where the flowing current may change abruptly in time, such as pulsed or stochastic currents.