Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Server cannot set content type after HTTP headers have been.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19585 |

    Hi Friends,

    I’m working on ASP.NET web page and would like to have a progress bar on a page where users should be able to download a zip file. I put a JavaScript in Page_Load but it fails with:

    this.Response.ContentType = “application/zip”;
    this.Response.AddHeader( “Content-Disposition”, “attachment; filename=YourFiles.zip” );

    The error message is: Server cannot set content type after HTTP headers have been sent.

    Do you have any ideas how to add the new header for the zip file? I tried Response.ClearContent() but with no success.

    Below is my code:

    this.Response.Write(“<div class=’style1′ id=’mydiv’ align=’left’ >”);
    this.Response.Write(“<span class=’style1′>”);
    this.Response.Write(“_”);
    this.Response.Write(“</div>”);
    this.Response.Write(“<script>mydiv.innerText = ”;</script>”);
    this.Response.Write(“<script language=javascript>;”);
    this.Response.Write(“var dots = 0;var dotmax = 30;function ShowWait()”);
    string load = “Preparing your Zip File. Please wait “;
    this.Response.Write(“{var output; output = ‘” + load + “‘;dots++;if(dots>=dotmax)dots=1;”);
    this.Response.Write(“for(var x = 0;x < dots;x++){output += ‘.’;}mydiv.innerText = output;}”);
    this.Response.Write(“function StartShowWait(){mydiv.style.visibility = ‘visible’; window.setInterval(‘ShowWait()’,500);}”);
    this.Response.Write(“function HideWait(){mydiv.style.visibility = ‘hidden’;window.clearInterval();}”);
    this.Response.Write(“StartShowWait();</script>”);
    this.Response.Flush();
    System.Threading.Thread.Sleep(3000);
    ///
    this.Response.ContentType = “application/zip”;
    this.Response.AddHeader( “Content-Disposition”, “attachment; filename=YourFiles.zip” );

    If you like to test it you can just paste my code in Page_Load.

    Thanks in advance for you help!

    Imported from legacy forums. Posted by rocko (had 3322 views)

    User (Old forums)
    Member
    Post count: 23064

    Xceed Zip for .NET does expose some progression events you can use to achieve this :

    http://doc.xceedsoft.com/products/FileSystemCore/doc/sources/handling_events.htm

    As for progressBar in ASP.NET, I did find the following article that could help :

    http://www.codeproject.com/aspnet/progressbar.asp

    Good luck !

    Imported from legacy forums. Posted by Matt (had 3279 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.