Independently from conventional electron beam based procedures, the photon beam based diagnostic is an alternative way for electron trajectory alignment and commissioning of numerous undulator cells in high-gain short-wavelength free-electron lasers (FELs). In this paper, using the microbunched electron beam and the undulator fine-tuning technique, a novel method based on the spatial profile analysis of coherent harmonic radiation from individual or two consecutive undulator segments, the so-called coherent photon beam based diagnostic, is proposed for undulator alignment and commissioning in seeded FELs. The preliminary experimental results at the Shanghai deep ultraviolet FEL test facility are presented. It shows that the proposed method is effective and convenient in the electron beam trajectory control, the undulator magnetic gap verification, and the phase match between two undulator segments.