zoukankan      html  css  js  c++  java
  • 解决网络 下载 句柄无效。 (异常来自 HRESULT:0x80070006 (E_HANDLE))

    首先要共享该文件

    其次 在安全里加IISSHARED 是IIS账号

    下载代码

      #region 下载
            /// <summary>
            /// 下载
            /// </summary>
            /// <param name="strPath"></param>
            /// <returns></returns>
            [LoginFilter]
            public ActionResult FilePathDownload(string strPath)
            {
                int index = strPath.LastIndexOf(@"");
                string fileName = "";
                if (index > 0)  
                {
                    fileName = strPath.Substring(index + 1, strPath.Length - index - 1);
                }
                int fileIndex=strPath.IndexOf(@"OrderFiles");
                var path = Server.MapPath("~/OrderFiles/" + strPath.Substring(fileIndex).Replace("\", "//"));
                return File(path, "application/x-zip-compressed", fileName);
                
            }
            #endregion

    页面

     <tr>
          <th>订单附件:</th>
          <td>
                            @if (Model.OrderFilesList.ToList().Count > 0)
                            {
                                var filePath = @Model.OrderFilesList.ToList().FirstOrDefault();
                                <a href="@filePath.FilePath" style="display:none">下载附件</a>
                              
                                using (Ajax.BeginForm("FilePathDownload", "ForeignTradeOrder", new { strPath = @filePath.FilePath }, new AjaxOptions
                                {
                                    HttpMethod = "Post"
                                }, new { id = "myForm" }))
                                {
                                   <a href="#" id="adown" onclick="downLoadClick()">下载附件</a>
                                   <input type="submit" id="btnDownLoad" style="display:none" value="下载附件"/>
                                }
                            }
                            else
                            {
                                 <span>无</span>
                            }
                            </td>
         </tr>     

    //下载
     function downLoadClick() {
        document.getElementById('myForm').submit();
    }

    IIS配置站点如下 站点下的虚拟目录盘符的路径如下

  • 相关阅读:
    helix matrix 螺旋矩阵
    利用基数排序生成100个1000以内顺序排列的随机数
    第三次随笔
    gSoap: How to add info to SOAP Header using gSOAP(转)
    sizeof empty class object
    C++基础回顾字符串地址比较
    (转)RVA相对虚拟地址解释
    团队建设历史经验回顾
    C++全局变量的生老病死
    C++基础回顾强制类型转换
  • 原文地址:https://www.cnblogs.com/liufei88866/p/3591795.html
Copyright © 2011-2022 走看看