在页面点击连接如何直接打开文件,而不是下载?点击页面的连接。本页面不关闭,文件直接弹出打开。如何实现????????

解决方案 »

  1.   

    谁帮忙阿。 sos了这么久了。。
      

  2.   

    直接写地址就行,最好是相对的:如<a href="image/1.gif">图片</a>
      

  3.   

    Response.AddHeader()方法用于输出一些描述信息,比如文件名,文件是下载还是直接打开,在这里,attachment代表下载,如果改为inline就是直接打开了
      

  4.   


        /// <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();
        }        
      

  5.   

    <a href="deal.aspx?参数=值"></a>
    传到deal.aspx中,然后在请求的页面中编码AddHeader
      

  6.   

    是在浏览器中间运行比如文本,pdf等文件还是直接在客户端电脑打开执行文件等文件?如果是在浏览器中查看文件的话, 就要看客服端浏览器是否支持打开此类型文件了. 如果是在客户端电脑直接打开的话, 好像要找黑客了.
      

  7.   

    - -。我在做一个asp.net 页面。 页面上有一个连接。点击连接,直接打开pdf文件可以阅读。
    不要下载的。
      

  8.   

    直接打开文档的话, 如果浏览器有文档查看的插件并且也开启了. 就<a href="***.doc">aaa</a> 就可以了. 如果想调用office word打开的话,就不行了.
      

  9.   

    如果需要直接打开pdf文件可以阅读。 需要对方浏览器安装了pdf查看的插件. 很多都没有装或者没有启用的.
      

  10.   

    还有一个办法就是模仿百度文库里面用flash打开.
      

  11.   

    这样能找不到网页?你路径给正确了没有啊??
    <a href="upload/Text.txt" target="_blank">查看文档</a>
    这样只要浏览器支持直接打开的文件(例如:文本文件,图片等)都可以的
      

  12.   


    报这个错 好像要在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'.