An innovative metrological method for freeform characterization in transmission as well as in reflection has been developed. The approach is based on diffraction theory and Fourier analysis with modified angular spectrum propagator. We analyze the propagation of a wavefront behind a two-dimensional cross grating and derive a universal method to measure the phase gradient directly from the recorded intensity distribution. This method works for arbitrary distances behind the grating. To prevent unwanted reflection while measuring in reflection and in transmission we use a two dimensional cross grating based on nanostructured black silicon. Our new formulation has been tested successfully through simulations. The wavefront generated by a freeform surface was measured with the new method. The experimental results are verified with a commercial Shack- Hartmann wavefront sensor.