In short, a file ASHX is an ASPX file, minus all plumbing ASP.NET webform.
I am using ASHX to generate PDF files on the fly, and download them.
Similarly, I use them to generate thumbnails on the fly and download them.
This could work very well with a blank ASPX, but ASHX files are much less resource-consuming.
Take a look at this tutorial to see how the files ashx.