问题一:
    小弟在登录CSDN时,不知道机器是中了什么蛊,不管是登录还是注册,提交时均抛出“未将对象引用到对象的实例”,换台机器就好。不知各位可曾遇到过。问题二: 
    在做下载附件时,我采用的是下面的代码。但保存后,我发现会在原文件后面加上我下载页面的HTML,然后我在最前面加了句Rsponse.Clear();还是没用,请大家帮我出出主意
    Response.ContentType = "application/octet-stream";
    Response.AddHeader("Content-Disposition", "attachment;FileName=1.txt");
    Response.Write("1.txt");

解决方案 »

  1.   

    我碰到过几次,当时也没在意,再来一次就好了,也想知道是什么原因。我用的是GreenBrower浏览器。
      

  2.   

    1。可能是你禁用cookies了
    2。
      

  3.   

    1.没遇到过
    2.你没结束Response
      

  4.   

    果然是没结束Response的问题。
    但打开还有一个问题提示
    “找不到文件: C:\Documents and Settings\sfgl1\Local Settings\Temporary Internet Files\Content.IE5\0VWFABO7\%2fTASK%2fUploadFile%2fTaskCommentAttachFiles%2f2006%2f06%2f06%2fb2b34abb-0f80-4f37-9f71-1114a445f74c[1].txt”我怎么来控制“/”和“\”呢?
      

  5.   

    string strFileName = "/TASK/UploadFile/TaskCommentAttachFiles/2006/06/06/b2b34abb-0f80-4f37-9f71-1114a445f74c.txt";Response.AddHeader("Content-Disposition", "attachment;FileName=" + strFileName);
    Response.Write(strFileName);用这样,然后打开文件就出现上面这个错误
      

  6.   

    1.没遇到
    2.string strFileName = @"/TASK/UploadFile/TaskCommentAttachFiles/2006/06/06/b2b34abb-0f80-4f37-9f71-1114a445f74c.txt";
      

  7.   

    1:没遇到过.2:<Script runat="server"> 
    Private Sub btnDownFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
            Dim strFileName as String = "中国.xls"  '取得下载文件
            processFiles(strFileName)
    End SubSub processFiles( strGetFile )
        Dim physicalFilePath as String = (Server.MapPath(".") + "/files/" + strGetFile)
        Dim stream As System.IO.FileStream = Nothing 
        Try 
            stream = New System.IO.FileStream(physicalFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)         Dim bufSize As Integer = CType(stream.Length, Integer) 
            Dim buf(bufSize) As Byte 
            Dim bytesRead As Integer = stream.Read(buf, 0, bufSize) 
            HttpContext.Current.Response.ContentType = "application/octet-stream"         HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(System.IO.Path.GetFileName(physicalFilePath)))        HttpContext.Current.Response.OutputStream.Write(buf, 0, bytesRead) 
            HttpContext.Current.Response.End 
        Finally 
            stream.Close 
        End Try 
    End Sub
    </Script>
      

  8.   

    旧的 GreenBrower 可能是用IE5.0的内核,用IE6.0内核的其它外壳软件大概就好了。
      

  9.   

    /// <summary>
    /// 文件下载
    /// </summary>
    /// <param name="FullFileName"></param>
    private void FileDownload(string FullFileName)
    {
      FileInfo DownloadFile = new FileInfo(FullFileName); 
      Response.Clear();
      Response.ClearHeaders();
      Response.Buffer=false;
      Response.ContentType="application/octet-stream";
      Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
      Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
      Response.WriteFile(DownloadFile.FullName);
      Response.Flush();
      Response.End();
    }