liaqat ali
liaqat ali

Reputation: 241

browser Does not open 'Save file' dialog box

I have uploaded a file on server and given a link to that file (test.txt file say) in my asp.net page. when i click on this link, it opens the content of that text file within the browser. But i want to open a dialog box so that user can save it on his local machine.

More over if file is dll type then it gives 404 error(file not found).

I tried it out in IE and Firefox and also its working fine on my local IIS but not on Server machine.

Upvotes: 0

Views: 1929

Answers (1)

philiphobgen
philiphobgen

Reputation: 2294

There are various ways suggested of forcing a file download to the browser in ASP.Net, and lots of examples ("asp.net file download"). Here's one: http://aspalliance.com/259

Basically, what you'l need to do is transfer the file to the browser 'in code' using Response.WriteFile() or something similar.

You'll also need to set a couple of response headers so that the browser knows this is a download as opposed to a file it should try and load: Content-Type and Content-Disposition

Personally, I'd rather zip a DLL if it is to be downloaded - after all a DLL is executable code, and could be blocked at the client side.

Upvotes: 2

Related Questions