locked
Upgrade of AjaxControlToolkit dreaded "Internet Explorer cannot download file" for IE7/8 when streaming files to browser RRS feed

  • Question

  • User1629385244 posted

    Hi, I've just upgraded to the latest AjaxControlToolkit (July 2013 release) and now my filedownloads have stopped working in IE 7/8.

    IE9, Firefox, Chrome etc are unaffected.

    My app basically takes a gridview which is embedded in an updatepanel and exports the contents to an Excel spreadsheet using code as below;

    Response.Clear()
    Response.AddHeader("content-disposition", "attachment;filename=myexcelfile.xls")
    Response.Charset = ""
    Response.ContentType = "application/vnd.xls"
    
    Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
    Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
    
    paycalc_GridView.RenderControl(htmlWrite)
    
    Response.Write(stringWrite.ToString())
    Response.End()

    Gridview and Export button are contanined within the UpdatePanel; a PostBack trigger has been added to the triggers section of the UpdatePanel.

    This worked in the previous version I was using, but now it doesn't.

    If I switch the scriptmanager from

    <ajaxToolkit:ToolkitScriptManager runat="Server" ID="ToolkitScriptManager1" CombineScripts="false"
            AsyncPostBackTimeout="15000" />

    back to

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    that also works.

    Also, this is over SSL.

    Hope someone can help?

    Friday, August 9, 2013 3:23 AM

Answers

  • User1629385244 posted

    Ok I'm going to add code to bump this along Wink

    I downloaded the June2013 release and it works! In the July2013 release it doesnt...

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="gridviewExport.aspx.vb"
        Inherits="testACTK_July2013.gridviewExport" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ToolkitScriptManager1" />
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="my_GridView" runat="server">
                    </asp:GridView>
                    <br />
                    <asp:LinkButton ID="export_LinkButton" runat="server">Export</asp:LinkButton>
                </ContentTemplate>
                <Triggers>
                    <asp:PostBackTrigger ControlID="export_LinkButton" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
        </form>
    </body>
    </html>
    

    Public Class gridviewExport
        Inherits System.Web.UI.Page
    
        Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) '    Confirms that an HtmlForm control is rendered for the specified ASP.NET
            '      server control at run time. */
        End Sub
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                my_GridView.DataSource = GetSomeData()
                my_GridView.DataBind()
            End If
        End Sub
    
        Protected Function GetSomeData() As DataTable
            Dim dt_tble As New DataTable
            Dim dt_row As DataRow
    
            dt_tble = New System.Data.DataTable("students")
            dt_tble.Columns.Add("id", GetType(Integer))
            dt_tble.Columns("id").AutoIncrement = True
            dt_tble.Columns("id").AutoIncrementSeed = 1
            dt_tble.Columns.Add("studentID", GetType(String)).DefaultValue = ""
            dt_tble.Columns.Add("studentULN", GetType(String)).DefaultValue = ""
    
            For i As Integer = 0 To 24
                dt_row = dt_tble.NewRow
                dt_row("studentID") = i + 100
                dt_row("studentULN") = "ABC" & i + 100
                dt_tble.Rows.Add(dt_row)
            Next
    
            Return dt_tble
        End Function
    
        Private Sub export_LinkButton_Click(sender As Object, e As System.EventArgs) Handles export_LinkButton.Click
            Response.Clear()
            Response.AddHeader("content-disposition", "attachment;filename=" & "myGridview" & ".xls")
            Response.Charset = ""
    
            Response.ContentType = "application/vnd.xls"
            Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
            Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
            Dim title As New Label
    
            my_GridView.RenderControl(htmlWrite)
    
            Dim myregex As New Regex("<(A|a)([ ]([a-zA-Z]+)=(""|')[^""\']+(""|'))*[^>]+>([^<]+)(</A>|</a>) ")
            '<(FONT|font)[^>]*>[^<]*(</FONT>|</font>) 
            Dim d As String = ""
            d = Regex.Replace(stringWrite.ToString(), "<(A|a)([ ]([a-zA-Z]+)=(" & Chr(34) & "|')[^" & Chr(34) & "\']+(" & Chr(34) & "|'))*[^>]+>([^<]+)(</A>|</a>)", "$6")
    
            Response.Write(d.ToString())
            Response.End()
        End Sub
    End Class




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 3:50 AM

All replies

  • User1629385244 posted

    Thanks for the links; doesnt solve my problem though...

    The export works fine with the June 2013 release, it has stopped working in the July 2013 release. Has something changed in the new release? Maybe something to do with the combinescripts handler?

    Monday, August 12, 2013 10:54 AM
  • User1629385244 posted

    Ok I'm going to add code to bump this along Wink

    I downloaded the June2013 release and it works! In the July2013 release it doesnt...

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="gridviewExport.aspx.vb"
        Inherits="testACTK_July2013.gridviewExport" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ToolkitScriptManager1" />
        <div>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="my_GridView" runat="server">
                    </asp:GridView>
                    <br />
                    <asp:LinkButton ID="export_LinkButton" runat="server">Export</asp:LinkButton>
                </ContentTemplate>
                <Triggers>
                    <asp:PostBackTrigger ControlID="export_LinkButton" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
        </form>
    </body>
    </html>
    

    Public Class gridviewExport
        Inherits System.Web.UI.Page
    
        Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) '    Confirms that an HtmlForm control is rendered for the specified ASP.NET
            '      server control at run time. */
        End Sub
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                my_GridView.DataSource = GetSomeData()
                my_GridView.DataBind()
            End If
        End Sub
    
        Protected Function GetSomeData() As DataTable
            Dim dt_tble As New DataTable
            Dim dt_row As DataRow
    
            dt_tble = New System.Data.DataTable("students")
            dt_tble.Columns.Add("id", GetType(Integer))
            dt_tble.Columns("id").AutoIncrement = True
            dt_tble.Columns("id").AutoIncrementSeed = 1
            dt_tble.Columns.Add("studentID", GetType(String)).DefaultValue = ""
            dt_tble.Columns.Add("studentULN", GetType(String)).DefaultValue = ""
    
            For i As Integer = 0 To 24
                dt_row = dt_tble.NewRow
                dt_row("studentID") = i + 100
                dt_row("studentULN") = "ABC" & i + 100
                dt_tble.Rows.Add(dt_row)
            Next
    
            Return dt_tble
        End Function
    
        Private Sub export_LinkButton_Click(sender As Object, e As System.EventArgs) Handles export_LinkButton.Click
            Response.Clear()
            Response.AddHeader("content-disposition", "attachment;filename=" & "myGridview" & ".xls")
            Response.Charset = ""
    
            Response.ContentType = "application/vnd.xls"
            Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
            Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
            Dim title As New Label
    
            my_GridView.RenderControl(htmlWrite)
    
            Dim myregex As New Regex("<(A|a)([ ]([a-zA-Z]+)=(""|')[^""\']+(""|'))*[^>]+>([^<]+)(</A>|</a>) ")
            '<(FONT|font)[^>]*>[^<]*(</FONT>|</font>) 
            Dim d As String = ""
            d = Regex.Replace(stringWrite.ToString(), "<(A|a)([ ]([a-zA-Z]+)=(" & Chr(34) & "|')[^" & Chr(34) & "\']+(" & Chr(34) & "|'))*[^>]+>([^<]+)(</A>|</a>)", "$6")
    
            Response.Write(d.ToString())
            Response.End()
        End Sub
    End Class




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2013 3:50 AM
  • User1629385244 posted

    Code above proves July2013 doesn't work in IE6/7/8.

    Anyone got any ideas? Or is this simple process broken in this release?

    Wednesday, August 21, 2013 6:29 AM
  • User-157013242 posted

    We're seeing the same problem with IE6/IE7/IE8 file downloads over HTTPs, even using the Dec 14, 2013 build of AjaxControlToolkit.

    Did anyone find a resolution to this problem?

    Thursday, January 2, 2014 1:03 PM