You just need to:
first, set your response mime type:
Response.Headers.Add("Content-Type", "application/pdf"); //for example
second, set following header as a dictate to browsers to download file:
Response.Headers.Add("Content-Disposition", "attachment; filename=foo.pdf"); //for example
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…