在页面点击连接如何直接打开文件,而不是下载?点击页面的连接。本页面不关闭,文件直接弹出打开。如何实现????????
解决方案 »
- 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面。
- repeater 未将对象引用到实例
- 图片热点提示问题
- DropDownList为什么会不断的加入数值
- 关于插入数据后,如何获得自动记录编号的问题
- Excel导入数据库问题:excel进程被占用怎么解决
- 首页调用的js是怎么实现的?
- 能不能在不使用<DIV>的情况下实现固定表头
- Frameset有2个窗体A1和A1,用脚本如何在窗体A1中给A2中的控件复值
- 怎样才能使自定义控件的属性Text像ImageButton的ImageUrl一样在VS.Net的属性修改器中打开的一个对话框选择路径?
- Repeater与DataList 的区别?
- 菜鸟学jquery求救
/// <summary>
/// Response.AddHeader实现下载
/// </summary>
/// <param name="filePath">完整的文件路径</param>
/// <param name="fileName">文件名</param>
private void DownFile(string filePath, string fileName)
{
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(Request.ContentEncoding.GetBytes(fileName))););
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();
}
传到deal.aspx中,然后在请求的页面中编码AddHeader
不要下载的。
<a href="upload/Text.txt" target="_blank">查看文档</a>
这样只要浏览器支持直接打开的文件(例如:文本文件,图片等)都可以的
报这个错 好像要在web.config 中注册pdf如何注册呢??There is no build provider registered for the extension '.pdf'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.