Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. File download problem in netscape

File download problem in netscape

Scheduled Pinned Locked Moved ASP.NET
helpsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MihirV
    wrote on last edited by
    #1

    hi all, i have a page that enables site user to download report files from the server. report file types are .pdf, .doc, .ppt and .xls for that what i am doing is creating a Stream from file and convert it into the byte and binary write the output... so it is working fine in IE but while using netscape, the download dialog concat the file name with .aspx ( fileName.pdf.aspx ), so netscape can not open the file with proper application.. any solution please help me, thanks in advance here i m giving my code for depth review the problem

    if ( File.Exists( sPathName ) )
    {
    using( FileStream oFStream = new FileStream( sPathName, FileMode.Open ) )
    {
    iFileLength = (int)oFStream.Length;
    buffer = new byte[iFileLength];					
    oFStream.Read( buffer, 0, iFileLength );
    oFStream.Close();
    }
    
    Response.Buffer = true;
    Response.Clear();					
    Response.ContentType = "application/" + Path.GetExtension( sPathName ).Remove(0, 1);
    
    Response.AddHeader( "Content-Type", "application/octet-stream" );
    Response.AddHeader( "Content-Length", iFileLength.ToString() ); 
    Response.AddHeader( "Content-Disposition", "attachment; filename=\"" + Path.GetFileName( sPathName ) + "\"; Size=" + iFileLength.ToString());
    
    Response.BinaryWrite( buffer );
    Response.Flush();
    }
    

    Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

    M 1 Reply Last reply
    0
    • M MihirV

      hi all, i have a page that enables site user to download report files from the server. report file types are .pdf, .doc, .ppt and .xls for that what i am doing is creating a Stream from file and convert it into the byte and binary write the output... so it is working fine in IE but while using netscape, the download dialog concat the file name with .aspx ( fileName.pdf.aspx ), so netscape can not open the file with proper application.. any solution please help me, thanks in advance here i m giving my code for depth review the problem

      if ( File.Exists( sPathName ) )
      {
      using( FileStream oFStream = new FileStream( sPathName, FileMode.Open ) )
      {
      iFileLength = (int)oFStream.Length;
      buffer = new byte[iFileLength];					
      oFStream.Read( buffer, 0, iFileLength );
      oFStream.Close();
      }
      
      Response.Buffer = true;
      Response.Clear();					
      Response.ContentType = "application/" + Path.GetExtension( sPathName ).Remove(0, 1);
      
      Response.AddHeader( "Content-Type", "application/octet-stream" );
      Response.AddHeader( "Content-Length", iFileLength.ToString() ); 
      Response.AddHeader( "Content-Disposition", "attachment; filename=\"" + Path.GetFileName( sPathName ) + "\"; Size=" + iFileLength.ToString());
      
      Response.BinaryWrite( buffer );
      Response.Flush();
      }
      

      Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Have you tried calling the Response.End right after the Flush method to make sure that no more data is added to the output stream of the response object?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups