我做的是在下载时候把相应的数据读出到输出流中。如果使用ie默认的下载可以下载到word文件,可是使用下载工具的时候下载下来的是我的aspx页面。
这是怎么回事?该怎么做才能下载到正确的文件.或者下载的时候自动使用默认下载?

解决方案 »

  1.   

    保存成临时文件,在trasnfer过去试一试
      

  2.   


    保存为临时文件?保存到服务器?具体是怎么个做法?我的代码如下:         Response.ClearHeaders();
            Response.ClearContent();
            Response.Clear();
            Response.Buffer = true;
            Response.Expires = -1;
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment;filename=test.doc");        HtmlTextWriter htw = new HtmlTextWriter(Response.Output);
            htw.WriteLine(@"<?xml version='1.0' encoding='utf-8' ?>");
            htw.WriteLine(@"<?mso-application progid='Word.Document'?>");
            htw.WriteLine(@"<?mso-application progid='Word.Document'?>");
            htw.WriteLine(@"<w:wordDocument xmlns:w='http://schemas.microsoft.com/office/word/2003/wordml' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:w10='urn:schemas-microsoft-com:office:word' xmlns:sl='http://schemas.microsoft.com/schemaLibrary/2003/core' xmlns:aml='http://schemas.microsoft.com/aml/2001/core' xmlns:wx='http://schemas.microsoft.com/office/word/2003/auxHint' xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' w:macrosPresent='no' w:embeddedObjPresent='no' w:ocxPresent='no' xml:space='preserve'>");
    ……………………(省略了其他)
             htw.WriteLine(@"<w:body><wx:sect>");
            htw.WriteLine(@"</wx:sect></w:body></w:wordDocument>");
            htw.Flush();
            htw.Close();        Response.End();