An HttpHandler would be a better choice for this type of functionality. Here is an example which goes over combining css and javascript files; it is not exactly what you are looking for but should get you headed in the right direction: http://www.codeproject.com/KB/aspnet/HttpCombine.aspx