save as dialog in asp.net

前端 未结 5 1425
醉酒成梦
醉酒成梦 2020-12-20 05:13

I have some data in the form of a string. I want to write this data to a file and save the file to the specified path. The path would be specified by opening a save as dialo

5条回答
  •  情深已故
    2020-12-20 05:25

    You could use a LinkButton (or regular link) and have the url point to a handler (ASHX) that retrieves the data and sends back a response with content disposition set to attachment. Write the data to the response. You'll also need to set up some other headers in the response -- such as content type and length. This would give the document (file) a regular link that could perhaps be bookmarked (if a regular link) in the future so that it can be retrieved again. You'd need to pass enough data in the query string to be able to identify which data is to be downloaded.

提交回复
热议问题