开发者

browser Does not open 'Save file' dialog box

开发者 https://www.devze.com 2023-03-09 00:03 出处:网络
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

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 t开发者_JAVA百科ried it out in IE and Firefox and also its working fine on my local IIS but not on Server machine.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号