提供便利,可在asp.net中下载文件 [英] giving facility to download the file in asp.net

查看:121
本文介绍了提供便利,可在asp.net中下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们.
我正在一个显示履历表的asp.net页面上工作.现在我希望用户能够下载该履历表.履历表既保存在数据库中,又保存在服务器上名为Jobseeker的文件夹中. 我应该怎么做.
在此先感谢大家.

hi guys.
i am working on an asp.net page which show resume .now i want the user,to be able to download that resume.resume is saved in both database and a folder named jobseeker on server .
how should i do it .
thank you all in advance friends

推荐答案

File Upload and Download in ASP.NET[^]

Hope this can help you.


您好,
创建一个ASPX文件,称为download.aspx.该文件以文件名作为参数,并在响应流中返回该文件的内容.在downanload.aspx.cs Page_Load事件上,请在下面使用此代码
Hi,
Create an ASPX file, called download.aspx. This file takes a file name as a parameter, and returns the contents of that file in the response stream.In your case the resume itself. On downanload.aspx.cs Page_Load event use this code below
Response.ContentType = "application/msword";
Response.AppendHeader("Content-Disposition","attachment; filename=resume.doc");
//Convert virrual path of requested file to physical path
Response.TransmitFile( Server.MapPath("~/resume/1.doc") );
Response.End();


这将提示用户下载请求的文件.添加的ContentType标头设置您的MIME类型,以便浏览器知道这是哪种文件.例如,如果您要提供MS Word文件以进行恢复,则应为应用程序/msword".八位字节流.您将在
此处 [


This will prompt user to download the requested file.The ContentType header which is added, sets your MIME type so that the browser knows what kind of file this is.For example, if you are serving an MS Word file for resume, this would be "application/msword". Octet-stream. You will get list of different Content Type here[^]

Hope this will help.


这篇关于提供便利,可在asp.net中下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆