devxlogo

Programmatically Force a Save As Dialog Box

Programmatically Force a Save As Dialog Box

Question:

Is it possible to force the file download box to appear through ASP? I want to create a file on the fly with the response.write method to fill its contents. The file should downloaded on the user’s machine through the dialog box with a user-defined filename as the default.

Answer:

Yes. Before you send your first response.write, change the content type to some weird type that the browser will not recognize. It will then prompt the user to download.

Response.ContentType = "application/xyzblah"Response.write "The contents blah blah blah"

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist