One reason you would write an .ashx file instead of an .aspx file is that your output is not going to a browser but to an xml-consuming client of some kind. Working with .ashx keeps you away from all the browser technology you don't need in this case.