1. Switch your Camera mode dial to aperture-priority; either Av (for Canon) or A (for Nikon).
2. Make sure your ISO is at the lowest possible setting. (ISO 100, 50 etc. depending on your camera)
3. Set your aperture at its narrowest (F/22, F/32, F/36 or F/45, depending on your lens).
4. Open a blank document in Microsoft Word, or any solid white background that you can open in your computer.
5. If youre using a zoom lens, zoom in to the telephoto end (ex. an 18-55 mm lenss telephoto end is its 55 mm focal length). Set the focus to infinity.
6. Now hold your camera really close to the monitor with the white background. Make sure you dont hit the monitor with your lens. (simply put, the aforementioned settings blur away any noticeable detail that could be taken by your camera)
7. Depending on the brightness of your monitor, the exposure time may well be within a few seconds. Take a picture while you move your camera around. Make sure that your camera is JUST moving within the white background. The movement blurs away any dirty object on your monitor that could be taken by your camera.
8. Review the picture. Spots and smudges indicate foreign matter on your sensor.
9. If you really want to clearly see the foreign matter. Put the test image into your computer and open it in Photoshop, then press CTRL + Shift + L for autolevels.
10. If you have a foreign object on the upper left portion of the test image, that means the foreign object is actually at the lower right portion of the sensor itself (when you face the camera)
Usually, these unwanted dirt are only visible to extremely narrow aperture settings that arent really used by most people frequently (F/16 - F/45 etc.) Try repeating the directions above, but set the aperture value to the setting that you use most of the time, like F/5.6, F/8.0 etc. If dirt is still present. Its time to clean your sensor.